Skip to content

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:

sh
pnpm exec playwright install
pnpm test
pnpm e2e
  • pnpm exec playwright install installs the browser binaries required by Playwright. On macOS, run this before the first pnpm e2e.
  • pnpm test runs the Jest suite for frontend unit and component tests.
  • pnpm e2e runs 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:

sh
vendor/bin/phpunit --configuration phpunit.xml --testsuite=unit
vendor/bin/phpunit --configuration phpunit.xml --testsuite=integration
vendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventions
  • unit covers isolated backend/domain behavior.
  • integration covers database, filesystem, service, and API boundary tests.
  • code-conventions checks architectural and naming conventions.

Current Runtime Snapshot

These numbers were measured locally on 2026-03-08. Expect them to vary by machine and environment.

SuiteCommandResultApprox. wall time
Frontend Jestpnpm testPass~20s
Frontend Playwrightpnpm e2eBlocked by missing env~1s before exit
PHP unitvendor/bin/phpunit --configuration phpunit.xml --testsuite=unitPass with warnings/skips~1.3s
PHP code-conventionsvendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventionsPass~0.3s
PHP integrationvendor/bin/phpunit --configuration phpunit.xml --testsuite=integrationFails 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.js
    • apps/backend/resources/javascripts/test/testSetup.js

Last observed result:

  • 114 passed suites, 2 skipped
  • 568 passed tests, 6 skipped
  • 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
  • Current projects:
    • setup account
    • chromium

The suite currently requires environment variables before it can start. At minimum:

  • SUPERADMIN_TOKEN

Optional environment used by the config/setup:

  • TESTS_BASE_URL
  • TESTS_ADMIN_BASE_URL
  • TEST_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:

  1. globalSetup checks SUPERADMIN_TOKEN and creates or reuses TEST_ACCOUNT_HASH.
  2. The setup account project opens /signup and creates a fresh account tied to that hash.
  3. 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:

sh
cd apps/backend
SUPERADMIN_TOKEN=... \
TESTS_BASE_URL=http://rock.prezly.test \
TESTS_ADMIN_BASE_URL=http://admin-api.prezly.test \
pnpm e2e

The 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:

  • 1438 tests
  • 3 warnings
  • 3 skipped

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:

  • 132 tests
  • 134 assertions
  • completed in under 1s

For a fast local signal, run tests in this order:

  1. vendor/bin/phpunit --configuration phpunit.xml --testsuite=code-conventions
  2. vendor/bin/phpunit --configuration phpunit.xml --testsuite=unit
  3. pnpm test
  4. vendor/bin/phpunit --configuration phpunit.xml --testsuite=integration
  5. pnpm e2e

This gives quick feedback first and leaves the slowest and most environment-dependent suites for last.