Testing
This repository has frontend tests in apps/backend and PHP test suites at the project root.
Quick Start
Frontend (apps/backend)
Run these from apps/backend:
pnpm exec playwright install
pnpm test
pnpm e2epnpm exec playwright installinstalls the browser binaries required by Playwright. On macOS, run this before the firstpnpm e2e.pnpm testruns the Jest suite for frontend unit and component tests.pnpm e2eruns the Playwright end-to-end suite.
Stable Environment
To make the tests reliable make sure you have:
- Latest PHP/composer deps +
php symfony cc - Latest npm deps
pnpm i - Correct snapshot of stripe data
PHP (project root)
Run these from the repository root:
vendor/bin/phpunit --configuration phpunit.xml --testsuite=unit
vendor/bin/phpunit --configuration phpunit.xml --testsuite=integration
vendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventionsunitcovers isolated backend/domain behavior.integrationcovers database, filesystem, service, and API boundary tests.code-conventionschecks architectural and naming conventions.
Current Runtime Snapshot
These numbers were measured locally on 2026-03-08. Expect them to vary by machine and environment.
| Suite | Command | Result | Approx. wall time |
|---|---|---|---|
| Frontend Jest | pnpm test | Pass | ~20s |
| Frontend Playwright | pnpm e2e | Blocked by missing env | ~1s before exit |
| PHP unit | vendor/bin/phpunit --configuration phpunit.xml --testsuite=unit | Pass with warnings/skips | ~1.3s |
| PHP code-conventions | vendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventions | Pass | ~0.3s |
| PHP integration | vendor/bin/phpunit --configuration phpunit.xml --testsuite=integration | Fails and exhausts memory | ~15m before crash |
Frontend Details
Jest
- Config:
apps/backend/jest.config.ts - Test files:
*.test.*and*.spec.* - Environment:
jsdom - Setup files:
apps/backend/resources/javascripts/test/testShim.jsapps/backend/resources/javascripts/test/testSetup.js
Last observed result:
114passed suites,2skipped568passed tests,6skipped- Jest-reported runtime:
18.319s
Playwright
- Config:
apps/backend/playwright.config.ts - Test directory:
apps/backend/resources/javascripts/e2e - Default base URL:
http://rock.prezly.test - Default
expect()timeout:- local:
7000ms - CI:
15000ms - override with
PLAYWRIGHT_EXPECT_TIMEOUT
- local:
- Current projects:
setup accountchromium
The suite currently requires environment variables before it can start. At minimum:
SUPERADMIN_TOKEN
Optional environment used by the config/setup:
TESTS_BASE_URLTESTS_ADMIN_BASE_URLTEST_ACCOUNT_HASH
Without SUPERADMIN_TOKEN, Playwright exits during global setup.
apps/backend/resources/javascripts/e2e/util/globalSetup.ts loads .env via dotenv, so local runs can provide these values through environment variables or a root .env file.
Playwright setup flow
The Playwright suite does more than browser automation:
globalSetupchecksSUPERADMIN_TOKENand creates or reusesTEST_ACCOUNT_HASH.- The
setup accountproject opens/signupand creates a fresh account tied to that hash. prepareAccount()calls the admin API to:- verify the account email
- promote the sender domain
- relax concurrent session limits for the license
This means a working run needs both the public app URL and an admin API URL that accepts the bearer token.
Example local invocation:
cd apps/backend
SUPERADMIN_TOKEN=... \
TESTS_BASE_URL=http://rock.prezly.test \
TESTS_ADMIN_BASE_URL=http://admin-api.prezly.test \
pnpm e2eThe CI setup in .github/workflows/preview.yml derives TESTS_ADMIN_BASE_URL from TESTS_BASE_URL and creates SUPERADMIN_TOKEN by provisioning a superadmin user plus API key inside the target environment.
PHP Details
Unit suite
- Declared in
phpunit.xml - Directory:
tests/unit - Bootstrapped through
tests/bootstrap/unit.php
Last observed result:
1438tests3warnings3skipped
Integration suite
- Declared in
phpunit.xml - Directory:
tests/integration - Additional notes:
tests/integration/README.md
Last observed result:
- multiple failures and errors before completion
- PHP fatal error due to memory exhaustion at
512MB - wall time about
15 minutes
Code-conventions suite
- Declared in
phpunit.xml - Directory:
tests/code-conventions
Last observed result:
132tests134assertions- completed in under
1s
Recommended Order
For a fast local signal, run tests in this order:
vendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventionsvendor/bin/phpunit --configuration phpunit.xml --testsuite=unitpnpm testvendor/bin/phpunit --configuration phpunit.xml --testsuite=integrationpnpm e2e
This gives quick feedback first and leaves the slowest and most environment-dependent suites for last.