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
bashnpx tsc --noEmit
npx tavo doctor
npx tavo check
npx tavo routesTest 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/routes.test.mjs
jsimport assert from "node:assert/strict";
import test from "node:test";
import { createPagesTestHarness } from "@tavojs/core/dev";
test("project route receives its loader data", async () => {
const app = createPagesTestHarness({
"/src/pages/projects/[id].tsx": {
load: ({ params }) => ({ id: params.id, name: "Website" }),
default: () => null,
},
});
const result = await app.runtime.resolvePathAsync("/projects/42");
assert.equal(result.status, 200);
assert.equal(result.route?.path, "/projects/:id");
assert.deepEqual(result.data, { id: "42", name: "Website" });
});
test("unknown URLs resolve to a 404", async () => {
const app = createPagesTestHarness({
"/src/pages/index.tsx": { default: () => null },
"/src/pages/404.tsx": { default: () => null },
});
const result = await app.runtime.resolvePathAsync("/missing");
assert.equal(result.status, 404);
});
Test the production shape
Install and configure Playwright before using the browser-test command (npm install --save-dev @playwright/test, then npx playwright install). Add application tests and a configuration with the correct baseURL and server startup command. 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
npxtavopreview--ssrin a separate terminal for manual SSR checks, or configure it as Playwright'swebServer.Inspect
.tavo/generated/build-report.jsonwhen a route or shared first load grows unexpectedly.Add
--max-first-load-jsand--max-route-jslimits when CI should enforce bundle budgets.
Run in Terminal
bashnpx tavo build --report-json
npx playwright testKeep 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.