Skip to content

Testing

Every test runs without a paid model call. Models are scripted, storage is in memory or in a temporary directory, and the browser talks to mocked routes. One command runs the lot.

pnpm verify

That is, in order:

Step What it checks
pnpm lint Biome’s lint and format checks over the repository, with warnings as errors.
pnpm check Workspace boundaries (declared dependencies, public exports only, no platform API in a portable package), then every production and test type check.
pnpm test Every unit and integration suite, then the terminal client’s native renderer tests.
pnpm build:worker, pnpm build:worker:ai The API Worker bundles, as dry runs: nothing is deployed.
pnpm build:web, pnpm build:docs, pnpm build:cli The web app, this site and the full-screen client build.
pnpm test:web:local Browser scenarios against a Vite server the runner starts and stops itself.

The Verify workflow runs the same checks on Linux, when someone starts it. While working on one package, run its own suite, for example pnpm --filter @felix/agent test.

Each workspace keeps its tests in src/test/, a tree that mirrors src/: src/conversation/store.ts is tested by src/test/conversation/store.test.ts, and a browser scenario is name.browser.ts in the same tree. A test that crosses modules lives with the package or app that owns the outcome. There is no repository-wide test folder.

  • Models. Scripted models come from @felix/ai/testing, and provider wire fixtures from @felix/ai/testing/anthropic. Neither is reachable through a runtime import.
  • API. Suites run the real routes and the typed client against scripted models and transactional in-memory storage, including authentication, error frames, disconnect cancellation and lease conflicts.
  • Terminal client. Suites use temporary directories for sessions and workspaces. The renderer tests mount the real screen on OpenTUI’s in-memory renderer (Node 26.4 or later, with --experimental-ffi), type and paste through its real input parser, and read the drawn frame.
  • Web app. Store, record and query suites run in Node. Browser scenarios drive Chrome through playwright-core against mocked API routes, at desktop and phone sizes.

Start from what must stay true, such as “a cancelled call never runs” or “a failed write does not advance the revision”. Write that as a failing test beside the code, then fix it.

For ordering and races, control the timing rather than sleeping: hold a promise open at the moment that matters (a history read, a tool start, a checkpoint), act, then release it. In renderer and browser tests, wait on the condition you expect, not on a fixed delay.

Assert what someone would observe: the saved messages, the revision, how many times a tool ran, whether cancellation reached it, and what is still on screen.

On macOS the scenarios use installed Chrome. Elsewhere, install the Chromium build that matches Playwright:

pnpm --filter @felix/web exec playwright-core install --with-deps chromium
pnpm test:web:local

FELIX_CHROME_PATH points at a different browser. pnpm test:web runs the same scenarios against a server you started, at FELIX_WEB_TEST_URL.