Chapter 10 / 14
Testing
Test layers
Pure unit tests cover rules, schemas, authorization, adapters, and generators. Sanic HTTP contract tests exercise routes through native request lifecycles. PostgreSQL and Redis conformance tests cover transaction, lock, expiry, idempotency, and queue behavior. Browser tests exercise generated PWA, slides, handbook, mobile, keyboard, print, and reduced-motion behavior.
Release gates
- Flask and maintained Node/TypeScript source-boundary checks.
- Alembic fresh-database, current-head, schema, backfill, parity, orphan, and rollback checks.
- Authentication, consent, erasure, tool, voice, telephony, and retention suites.
- Deterministic browser/CSS/native/vendor artifact rebuilds and manifest hashes.
- Vercel bundle, static serving, OTA signing/store, and production health probes.
Running tests
Use the API virtual environment: API/.venv/bin/python -m pytest. Run focused tests during red/green development, then the full affected suite. Tests requiring loopback sockets or Chromium must run in an environment that permits them; a sandbox permission error is not an application assertion.
Generated output is checked twice: the builder must reproduce checked-in bytes, and deployment asset hashes must match those bytes.