Spacerr uses TypeScript, ESLint, Bun tests, Playwright, and feature owned tests to keep the product safe to extend. The goal is simple: run fast checks while building, then run full end to end checks before shipping risky changes.
The current kit includes 32 unit tests and 77 E2E tests across billing, auth, admin, blog, settings, contact, AI chat, and widget behavior.
Commands
Use these commands during development.
bun run lint
bun run test:unit
bun run test:e2e
bun run test:all
bun run buildbun run lint runs TypeScript with tsc --noEmit and ESLint.
bun run test:unit runs Bun tests under src.
bun run test:e2e installs the Chromium browser if needed and runs Playwright with .env.local.
bun run test:all runs unit tests and end to end tests.
bun run build checks the production Next.js build.
Test Ownership
Tests are owned by the feature they cover.
src/features/auth/tests
src/features/blog/tests
src/features/admin/tests
src/features/billing/tests
src/features/contact/tests
src/features/settings/tests
src/features/ai/chat/tests
src/features/ai/widget/testsShared helpers can live in root test helper folders such as e2e/helpers, but actual feature behavior tests should stay inside the owning feature.
This keeps tests easy to find when you change a feature.
Test IDs
Reusable test IDs should live in feature owned constants files.
src/features/ai/chat/constants/ai-chat-test-ids.ts
src/features/auth/constants/auth-test-ids.tsUse constants from components and tests instead of hardcoding data-testid strings in many places.
Route Helpers
Tests should use route helpers instead of duplicating route strings.
Use WebRoutes for pages and ApiRoutes for API paths.
WebRoutes.dashboard.path
WebRoutes.blog.path
ApiRoutes.billing.statusThis keeps tests stable when a route changes.
End To End Tests
Playwright tests exercise real browser flows.
bun run test:e2eUse the UI runner when debugging a failing browser flow.
bun run test:e2e:uiUse debug mode when you need step by step inspection.
bun run test:e2e:debugE2E tests need .env.local because they create users, sign in, hit API routes, and sometimes touch the database or provider backed flows.
E2E tests can very rarely be flaky because they combine browser timing, mocked AI streams, persisted query cache, realtime updates, and route transitions. If one fails once, rerun it before assuming the product is broken. Playwright retries E2E failures once locally and twice in CI, so real deterministic bugs should still keep failing.
CI Recommendation
Add CI and make it run the full test command so every important check runs before changes ship.
bun install
bun run lint
bun run test:all
bun run buildbun run test:all runs the unit and end to end test suites. Make sure CI has the required environment variables for the flows you want it to test.