Skip to content

Testing

Testing#

Use @kamod-ch/otok-test for server-side tests and Playwright for browser behavior.

import { createOtokTestApp, authenticatedSession } from "@kamod-ch/otok-test";

const app = await createOtokTestApp({
  routes: [{ path: "/dashboard", component: ({ params }) => <p>Dashboard</p> }],
  plugins: [],
});

const response = await app.get("/dashboard", { session: authenticatedSession });
expect(response.status).toBe(200);
await app.cleanup();

Legacy helpers such as createTestApp, renderRoute, and renderParsedRoute remain available.

import { createTestApp, renderParsedRoute } from "@kamod-ch/otok-test";

const app = createTestApp({
  routes: [{ path: "/users/:id", component: ({ params }) => <p>User {params.id}</p> }],
});

const { document } = await renderParsedRoute(app, "/users/123");
expect(document.getText("p")).toContain("User 123");

Use @kamod-ch/otok-test/client with Vitest’s jsdom environment for island hydration and soft-navigation unit tests. Use Playwright for full browser coverage.

See the repository’s docs/testing.md for the full test matrix.