Testing (factories + route client)
defineFactory builds typed, seeded test data; testRoute(module) calls a route's loader/action with a synthesized request so you can assert on the result — no server, no DOM. The assertions below run live, with the same helpers you'd use in bun test.
Tip
For component testing (render + query + interact in a happy-dom DOM), use @bext-stack/framework/testing. testkit is pure (no DOM dependency) and targets app logic: data via factories, routes via testRoute.
Factory-generated data
| u0 | user0@acme.co | admin |
| u1 | user1@acme.co | member |
| u2 | user2@acme.co | admin |
Live assertions
✓rejects an invalid signup (bad email + underage)pass
✓accepts a valid signup and coerces age to a numberpass
✓factory make() applies overrides (role = admin)pass
import { defineFactory, cycle, testRoute } from "@bext-stack/framework/testkit";
import * as signup from "../app/signup/page"; // your route module
const userFactory = defineFactory((n) => ({
id: `u${n}`, email: `user${n}@example.com`, role: cycle("admin", "member")(n),
}));
test("rejects an invalid signup", async () => {
const route = testRoute(signup);
const res = await route.post({ email: "nope", age: "12" }); // calls the action
expect(res.ok).toBe(false);
});
test("loader reads query params", async () => {
expect(await testRoute(signup).get({ ref: "promo" })).toMatchObject({ ref: "promo" });
});