Frontend testing¶
The frontend test stack has five layers:
deno task test:unitruns Deno business-logic and fixture tests.deno task test:coreruns the focused Vitest core-logic suite.deno task test:componentruns Svelte component tests inhappy-dom.deno task test:e2eruns Chromium against an isolated real backend and Vite frontend.deno task test:visualcompares the Linux Chromium visual baselines.
Run all frontend checks with deno task test:frontend.
deno task test:coverage enforces a 60% minimum for statements, branches,
functions, and lines across maintainable core logic in
src/lib/{domain,features,shared}. The exact includes and exclusions are
defined in frontend/vitest.config.ts; generated parsers and selected browser-only
modules are outside the core coverage surface. The core HTML and LCOV reports are written
to coverage/core.
Component coverage remains informational because route, chart, and Svelte
rendering code has a different testing cost profile. Its HTML and LCOV reports
are written to coverage/component. deno task test:coverage:report generates
both reports without enforcing the core threshold, which is useful while
investigating a temporary regression. Reports from different instrumentation
runners are not concatenated or treated as one coverage measurement.
Nix and Playwright¶
Enter nix develop before running browser tests. The shell supplies the
Chromium build matching Playwright 1.61.1 through PLAYWRIGHT_BROWSERS_PATH;
browser downloads are not required.
The browser server copies the browser fixture journal and config into a
temporary directory, builds paisa.db with paisa update, seeds portfolio
holdings, uses UTC and the fixed date 2022-02-07, and removes the temporary
database after the run.
API regression fixtures¶
Integration tests under frontend/tests/fixture/ keep committed JSON API
baselines plus journal/config source files. paisa.db files are not versioned;
each test run copies source files to a temporary directory and rebuilds the
database from the journal during sync.
make regen-fixtures rewrites JSON baselines when API output changes. Regen
writes id-stripped JSON, so diffs show only meaningful schema or value changes.
make normalize-fixtures can strip generated ids from existing baselines without
re-running the server.
Updating visual baselines¶
Run deno task test:visual:update inside the Linux Nix shell, review every
changed PNG, and commit intentional changes. Do not update screenshots merely to
make a failing test pass.
Failed CI runs upload coverage, playwright-report, and test-results
artifacts for seven days. Pull requests run the frontend suite, while direct
pushes run it only on master; stale runs are cancelled when a newer commit is
pushed. Documentation-only changes are skipped. The cross-platform packaged
desktop launch smoke runs weekly on Sunday and can be dispatched manually from
GitHub Actions.