CLI
Run the integration suite against disposable services. The test environment supplies its own actors and data so that the tests can exercise complete application flows.
yarn test:integration:ephemeral executes yarn mercato test:integration.
The command starts a disposable Postgres container and app runtime, runs the Playwright suite, and tears everything down when tests finish.
# Preferred script
yarn test:integration:ephemeral
# Code coverage report from integration tests
yarn test:integration:coverage
# Interactive menu (persisted ephemeral environment)
yarn test:integration:ephemeral:interactive
# Direct CLI command (alias form)
yarn mercato test:integration
# Direct CLI command (module/command form)
yarn mercato test integration
# Direct CLI command (interactive menu)
yarn mercato test:integration:interactive
# or
yarn mercato test interactive
# Direct CLI command (coverage)
yarn mercato test:integration:coverage
# or
yarn mercato test coverage
Native integration helpers read the following optional variables before tests load:
| Role | Password | |
|---|---|---|
| Superadmin | OM_INIT_SUPERADMIN_EMAIL | OM_INIT_SUPERADMIN_PASSWORD |
| Admin | OM_INIT_ADMIN_EMAIL | OM_INIT_ADMIN_PASSWORD |
| Employee | OM_INIT_EMPLOYEE_EMAIL | OM_INIT_EMPLOYEE_PASSWORD |
Pass the credentials of the actors created in your disposable environment to the test process.
These settings select existing actors; they do not change application passwords.
Each field resolves independently: process environment first, then the existing
apps/mercato/.env or root .env lookup. With no value, helpers retain the seeded
role email (<role>@acme.com) and seeded password. Set the variables before starting
Playwright because role defaults are captured when the helper module loads.
Both browser login(page, role) and API getAuthToken(request, role) use these defaults.
An explicit password argument to getAuthToken continues to take precedence.
Keep secrets out of command history, test output, screenshots and committed files.
Use yarn test:integration:coverage to measure real Open Mercato runtime code coverage driven by integration tests.
The command:
.ai/qa/test-results/coverage/code/ (index.html, lcov.info, coverage-summary.json)Options for yarn test:integration:coverage:
--filter <pattern> or positional <pattern> to run subset of tests--workers <n> and --retries <n> passed to Playwright--verbose--screenshots / --no-screenshots--no-reuse-env always starts a fresh ephemeral runtime (never attaches to existing .ai/qa/ephemeral-env.json)--json outputs machine-readable totals--keep-raw-v8 keeps raw process coverage files in .ai/qa/test-results/coverage/raw-v8/Environment overrides:
OM_INTEGRATION_APP_READY_TIMEOUT_SECONDS=<seconds> increases the ephemeral app readiness timeout (default 90). This is the knob to raise in slower CI runners, for example OM_INTEGRATION_APP_READY_TIMEOUT_SECONDS=180 yarn test:integration:coverage.If you still need scenario/spec mapping coverage:
yarn test:integration:spec-coverage
| Option | Description |
|---|---|
--filter <pattern> | Runs only tests matching a Playwright filter (same as positional filter). |
<pattern> | Positional shorthand for --filter. |
--keep | Keeps app and database running after tests (for debugging). |
--verbose | Shows detailed bootstrap/build logs. |
--screenshots | Forces screenshot capture during test runs. |
--no-screenshots | Disables screenshot capture during test runs. |
--no-reuse-env | Forces a new ephemeral app+DB instance instead of reusing an existing one. |
# Run everything in ephemeral containers
yarn test:integration:ephemeral
# Run only auth-related tests
yarn mercato test:integration --filter auth/
# Keep environment alive for debugging after tests
yarn mercato test:integration --keep --verbose
# Always start a new ephemeral runtime (no attach/reuse)
yarn mercato test:integration --no-reuse-env
yarn test:integration:ephemeral is optimized for clean, fully isolated runs, not for quick iteration. For day-to-day development, use one of these faster patterns:
# 1) Start interactive ephemeral mode once (preferred)
yarn test:integration:ephemeral:interactive --no-screenshots
# 2) Run only the test you are changing against that running environment
BASE_URL=http://127.0.0.1:<port> npx playwright test --config .ai/qa/tests/playwright.config.ts sales/TC-SALES-007.spec.ts --retries=0
# 3) Run with more workers locally when tests are independent
BASE_URL=http://127.0.0.1:<port> npx playwright test --config .ai/qa/tests/playwright.config.ts --workers=4 --retries=0
# 4) Keep ephemeral mode but filter aggressively
yarn test:integration:ephemeral -- --filter sales/TC-SALES-007.spec.ts --no-screenshots
Notes:
.ai/qa/ephemeral-env.json; read baseUrl from this file before running manual Playwright commands.5001 when available; fallback ports are recorded in .ai/qa/ephemeral-env.json.--workers only if tests do not share mutable state.yarn test:integration:ephemeral for pre-merge confidence and CI parity.24.xdocker info must succeed)Use interactive mode when you want to keep one ephemeral app/database running and execute multiple tests without re-bootstrapping each time.
yarn test:integration:ephemeral:interactive
The command writes active environment details to .ai/qa/ephemeral-env.json and clears the file when the environment is closed.
Menu actions:
crm) to filter the visible list interactively by path/descriptiona)show-report)After each test run, the CLI asks whether to:
h)q)Supported options:
--verbose--screenshots--no-screenshots--workers <n>--retries <n>--no-reuse-env