Skip to content

Automated Testing

Automated tests run on every pull request via GitHub Actions and give the team fast confidence that existing functionality hasn't been broken. They complement — but don't replace — the manual QA process documented in Test Execution and Retesting & Regression Testing.


Overview

The platform uses two automated testing layers:

Layer Tool What it covers Who writes it
API E2E Jest + NestJS test utilities HTTP endpoints — auth, CRUD, permissions, validation Developers
Frontend E2E Playwright Customer-facing user flows in the browser Developers

Unit tests exist for critical utility code (e.g. environment validation) but the primary automated coverage strategy is integration-level — testing real HTTP calls against a real test database.


When tests run

Trigger What runs
Pull request opened or updated API e2e suite + lint + build (affected projects only)
Merge to development Same as PR, then deploys to dev if passing
Merge to main Same as PR, then deploys to production; Playwright smoke tests run against staging

Tests must pass before a PR can be merged. If CI fails, check the GitHub Actions run for the failing spec and fix before requesting review.


Developer workflow

When building a new feature or fixing a bug, the expectation is:

Write the code → Write or update the relevant test → Open PR → CI runs → Tests pass → Review

Specifically:

  • New API endpoint → add or update the spec file in apps/api-e2e/src/api/<module>/
  • New customer-facing frontend flow → add a Playwright test in apps/customer-frontend-e2e/src/
  • Bug fix → verify the failing scenario is covered by a test (add one if not) so it can't regress

Every PR includes a testing checklist. If a box can't be ticked, add a note explaining why.


PR checklist

The following appears in every pull request template:

## Testing
- [ ] API e2e spec added or updated for any changed endpoints
- [ ] Playwright test added for any new customer-facing flows
- [ ] Tests pass locally before opening PR
- [ ] ClickUp sub-task "Write tests: <feature>" created if this is a larger feature

Local setup

API e2e

Requires a dedicated test database container (separate from the dev database to avoid data loss):

docker compose up -d db_test

The test database runs on port 3307. Ensure your .env.test file exists at the project root — copy from .env.example if not:

cp .env.example .env.test

Update .env.test so NODE_ENV=test and MIKRO_ORM_PORT=3307.

Run all API e2e tests:

pnpm nx e2e api-e2e

Run a specific spec file:

pnpm nx e2e api-e2e --testPathPattern orders.spec

Run a specific test within a spec:

pnpm nx e2e api-e2e --testNamePattern "should return 401"

Playwright (frontend)

Playwright auto-starts the frontend preview server before running. No manual setup required:

pnpm nx e2e customer-frontend-e2e

To run against a specific URL (e.g. staging):

BASE_URL=https://staging.yourapp.com pnpm nx e2e customer-frontend-e2e

Gap backlog

The following API modules don't have e2e coverage yet. They should be covered as part of feature work or as dedicated tasks:

Priority Module Notes
1 orders Core business flow
2 carts Prerequisite for checkout
3 payments Stripe — mock external calls
4 discount-codes / discount-carts
5 shipping-rules
6 storefronts (admin CRUD)
7 notifications
8 xero Mock external calls

Frontend Playwright coverage is also being built out. See Frontend E2E Tests for the roadmap.