Router that virtually distributes inference across connected devices in the home.
Go
Tests
Vitest runs the active modular unit project by default.
tests/
fixtures/ # Reusable, typed test infrastructure (no test files here)
modular/ # Active unit tests
Commands
| Command | What it runs |
|---|---|
npm test |
Active modular unit suite |
npm run test:unit |
tests/modular/**/*.test.ts |
npm run test:unit:watch |
Modular unit tests in watch mode |
npm run typecheck:test |
tsc --noEmit -p tsconfig.test.json |
npm run typecheck |
All three projects: web, node, and test |
npm run test:clean |
Wipe Vitest cache and leftover tmpdirs |
Avoiding mock hell
Three rules:
- Use typed mocks. Parameterize
vi.fnwith the real function type. - Mock at module boundaries. Keep production source free of test-only switches.
- Prefer shared wire/types coverage. Tests should validate the current UI contract and shared utilities.
Isolation invariants
Setup-files in tests/fixtures/isolation.ts enforce the following at every
test load:
- Network: An axios request interceptor blocks any request whose host
is not
127.0.0.1/localhost/::1. Tests that need HTTP must spin up a local fake (tests/fixtures/release-server.ts). PAIR_USER_DATAis set to a per-worker tmpdir so unit/contract tests that inject aPathProvider(viainitPlatform) never write to the dev's real userData. Tests that want a different path can override it explicitly.- Sandboxing of destructive subsystems is the responsibility of the test
runtime. In-process tests use
vi.mockat module boundaries. There are noPAIR_TEST_DISABLE_*env vars in production source. assertIsolated()verifiesPAIR_USER_DATAis set and lives underos.tmpdir(). Call from any test that touches the file-config-store.- Tmpdir tracking:
createTmpUserData()registers anafterEachcleanup. A teardown leak failsafterAllwith the leaked paths.
Adding a new test
Add unit coverage under tests/modular/<area>/<file>.test.ts. Use direct
imports for pure code and module-boundary mocks for process, network, or
filesystem effects.
Type discipline
The same discipline as production source applies:
- No
as any/as unknown/as Type/: any. Same as production. vi.fn<typeof realFn>()for every mocked function.implementsfor every reusable fake.- Fixtures are typed
.tsmodules, not raw JSON. vi.mocked(realFn)for assertion access — never cast.