A test & QA harness in TypeScript — deterministic Vitest unit tests plus
Playwright end-to-end tests that drive a real HTTP service. The E2E suite runs
in Playwright's API mode (the request fixture), so the whole thing is green in
CI without downloading a browser; add one line to extend it to full browser
E2E.
- Unit tests done right (
src/retry.ts+tests/) — a retry-with-backoff primitive whose every non-deterministic input (clock, jitter) is injectable, so the policy is asserted to the millisecond. Nosleep, no flake. - E2E that actually exercises a service (
e2e/) — Playwright boots the target API viawebServer, waits for/healthz, then tests real request/response, validation (400), and routing (404). - Point it at anything — set
BASE_URLand the E2E suite runs against any running service (e.g. the siblingmarketpulsegateway), not just the bundled demo server.
npm install
npm test # vitest (5) + playwright (4)
npm run test:unit # just the unit tests
PORT=9090 npm run test:e2e # e2e on a chosen port
BASE_URL=http://localhost:8080 npm run test:e2e # against a real serviceEverything is one command in a container:
docker build -t sentinel . && docker run --rm sentinel| Path | Role |
|---|---|
src/retry.ts |
Unit-under-test: injectable backoff/jitter/sleep. |
tests/retry.test.ts |
Vitest — success, retry, exhaustion, backoff math, cap. |
e2e/server.ts |
Small target API (self-contained demo). |
e2e/api.spec.ts |
Playwright API E2E — health, echo, 400, 404. |
playwright.config.ts |
webServer boot + health-gate; PORT/BASE_URL configurable. |
- Determinism over sleeps. Tests inject
sleep/jitter; the suite never waits on wall-clock time, so it's fast and non-flaky. - No hidden browser download. API-mode E2E keeps CI light; browser specs are a
documented one-liner (
npx playwright install chromium) away.
The test/QA layer of a small polyglot portfolio — Go for networking, Python for high-level AI, TypeScript here, Rust for the from-scratch numerical core. — Nicholas Martins · github.com/nickmartins-lambda