Navigated to /docs/getting-started/testing-and-diagnostics

Testing and diagnostics

Check route behavior, project health, production rendering, and browser flows before a change reaches users.

Run the narrowest useful check

Use TypeScript and focused tests while editing, then widen the feedback loop as a change approaches release. Tavo.js diagnostics check the application shape and generated route contract without replacing tests for your product behavior.

Run in Terminal

BASH
bashnpx tsc --noEmit
npx tavo doctor
npx tavo check
npx tavo routes

Test routes without a browser

createPagesTestHarness resolves an in-memory page map with the same route conventions used by the application. Use it for fast route, loader, middleware, and error-path tests; keep DOM interaction and hydration assertions in a real browser.

Create tests/pages/index.test.tsx

TSX
tsximport { createPagesTestHarness } from "@tavojs/core/dev";
import { Text } from "@tavojs/ui";

const app = createPagesTestHarness({
  "/src/pages/index.tsx": {
    default: () => <Text>Project dashboard</Text>,
  },
});

export async function homePageResolves() {
  const result = await app.runtime.resolvePathAsync("/");
  if (
    result.status !== 200 ||
    result.pathname !== "/" ||
    result.route?.path !== "/"
  ) {
    throw new Error("Home page did not resolve successfully");
  }
}

Test the production shape

A production build discovers routes, compiles client and server output, prerenders static pages, and reports JavaScript cost. SSR preview exercises the generated server entry rather than the development transform pipeline.

  • Exercise direct requests, client navigation, actions, 404 and error pages, and hydration in browser tests.

  • Start npx tavo preview --ssr in a separate terminal for manual SSR checks, or configure it as Playwright's webServer.

  • Inspect .tavo/generated/build-report.json when a route or shared first load grows unexpectedly.

  • Add --max-first-load-js and --max-route-js limits when CI should enforce bundle budgets.

Run in Terminal

BASH
bashnpx tavo build --report-json
npx playwright test

Keep runtime evidence actionable

Development diagnostics identify route, mount, patch, and hydration phases. Start with the first server-client divergence and its DOM path; suppressing the warning leaves the underlying ownership or rendering mismatch in place.

Production logs and instrumentation should record route patterns, phases, timing, and stable diagnostic codes. Exclude request bodies, cookies, tokens, and loader results unless the application has an explicit redaction policy.

Checkpoint

Next steps