[Testing reference]

AXIS unit, worker, security, coverage gate, and Playwright e2e conventions with paths and commands.

Testing reference

Abstract

AXIS tests are Bun-first under frontend/, with Playwright for browser smoke and a scoped coverage ratchet. Canonical human guide: frontend/TESTING.md. This page is the reference map for agents and contributors.

Conceptual model

Commands

cd frontend

bun run test                 # unit + worker tests
bun run test:unit            # frontend/tests only
bun run test:coverage        # lcov + text → coverage/
bun run test:coverage:gate   # coverage + 95% scoped gate
bun run test:security        # tests/security/
bun run test:e2e:smoke       # Playwright @smoke
bun run test:e2e:critical    # @smoke|@critical
bun run test:e2e             # all
bun run test:all             # gate + security

Root:

bun run test:frontend
bun run test:frontend:coverage
make test-frontend

Layout

frontend/tests/
  setup.ts
  fixtures/
  helpers/
  *.test.ts
  integration/
  security/
frontend/scripts/check-coverage.mjs
frontend/e2e/
  smoke.spec.ts
frontend/playwright.config.ts
frontend/worker/tests/
  auth.test.ts
  keys-*.test.ts
  scripts*.test.ts
  …

Coverage policy

ItemPolicy
Gate95% lines on scoped core
Ratchet history70 → 80 → 83 → 87 → 90 → 95
Includeplugins, storage (minus idb), store, results, sources, streams, data, chart pure helpers + series-factory/manager-access, worker auth/keys/runtime/scripts
Exclude from gatedrawing-layer.ts, pane-manager (unit elsewhere), runner chart apply, pyodide boot, legacy JS, Solid UI .tsx
Full reportbun test --coverage unscoped

Conventions

  1. import './setup' first when tests touch store/plugins/storage.
  2. No real network — mock fetch / WebSocket.
  3. Table-driven tests for catalog built-ins.
  4. Plugin fixtures in tests/fixtures/plugins/.
  5. Prefer calling handlers with fake params over full browser for unit scope.

Playwright

Config (playwright.config.ts):

  • testDir: ./e2e
  • Chromium project
  • webServer: bun run build && bun run preview -- --host 127.0.0.1 --port 4173
  • baseURL: http://127.0.0.1:4173 (override AXIS_E2E_BASE)
  • Timeout 60s; CI retries 1

Smoke mocks /run and Binance. Use data-testid attributes (axis-btn-load, axis-manager, …).

Security suite

bun run test:security covers:

  • Plugin URL scheme rejection
  • Storage-via-URL rejection
  • Poisoned localStorage
  • Worker partition isolation
  • If-Match 409
  • Admin keys

Adding a unit test

  1. Create frontend/tests/<area>.test.ts.
  2. Import setup if needed.
  3. Use fixtures under tests/fixtures/.
  4. Run bun run test:unit and bun run test:coverage:gate.

CI linkage

See CI and testing for workflow job names and nightly schedule.

Failure modes

FailureMitigation
Coverage dropAdd tests in scoped files or deliberately exclude only with policy change
E2E flakeMock network; single worker; stable testids
IDB in unitLocal storage falls back to memory maps

See also