Announcements
Preview Your Storefront
End-to-End Testing with CodeceptJS
Track Storefront Next Activity with Analytics
CLI Reference
B2C Commerce Release Notes
Ask the Community
Your Storefront Next app includes an end-to-end test suite built with CodeceptJS and Playwright. Run automated tests against your storefront locally or in a remote environment to verify that user-facing flows work as expected.
Configure the storefront app from the project root.
Copy .env.default, the included environment template, or start from any .env file you already have configured.
1cp .env.default .envEdit .env with your B2C Commerce credentials.
From the project root, install dependencies.
1pnpm installThis step also installs Playwright browsers.
Copy the environment template from the e2e directory.
1cp e2e/.env.sample e2e/.envThis table describes the key variables in .env.
| Variable | Default | Description |
|---|---|---|
BASE_URL | http://localhost:5173 | Storefront URL |
SITE_ID | RefArchGlobal | B2C Commerce site ID |
SITE_ALIAS | global | URL prefix for multisite routing |
LOCALE | en-GB | Locale prefix for multisite routing |
HEADLESS | false | Run browser headless |
VERBOSE | false | Get more debug logging and stack traces during test runs. |
1# Run all tests against a running storefront
2pnpm e2e
3
4# Auto-start local dev server and run tests
5pnpm e2e --mode=localRun all commands from the template root.
| Command | Description |
|---|---|
pnpm e2e | Run all tests |
pnpm e2e --mode=local | Auto-start local dev server and run tests |
pnpm e2e --mode=remote | Run against a remote URL (requires BASE_URL) |
pnpm e2e --grep "@checkout" | Filter tests by tag or name |
pnpm e2e --headed | Run tests with the browser visible |
pnpm e2e --ui | Open interactive UI mode |
pnpm e2e --debug | Debug with the CodeceptJS inspector |
pnpm report | Open the Allure test report |
The test suite integrates with CodeceptJS AI to provide self-healing tests, an interactive debugging console, and automatic page object generation. AI features are disabled by default. To use them, pass the --ai flag.
Get an API key from console.anthropic.com.
Add the key to .env.
1ANTHROPIC_API_KEY=sk-ant-...Run tests with AI enabled.
1pnpm e2e --aipause() to a test, then describe actions in plain English.I.askForPageObject() to read the live document object model (DOM) and generate a page object.To see AI healing decisions in the console, run:
1DEBUG="codeceptjs:ai" pnpm e2e --aiAI coding assistants such as Cursor and Claude Code can generate complete E2E tests using the generate-storefront-e2e-test skill. This is separate from the Anthropic API key used for runtime self-healing—no additional API key is required.
The skill guides the assistant through a structured workflow, from understanding the commerce scenario to producing spec files, page objects, and self-healing recipes.
Ask your AI assistant to create an E2E test. Any of these prompts activates the skill.
1"Create an E2E test for the checkout flow"
2"Write a test that validates product search"
3"Add E2E coverage for the shopping cart"The assistant:
src/pages/index.ts, src/flows/index.ts, and helpers/self-healing/recipes.tsThis table describes the files the skill produces.
| Artifact | Location | Purpose |
|---|---|---|
| Spec file | src/specs/<feature>/*.spec.ts | Test scenarios with Chai assertions |
| Page object | src/pages/*.page.ts | Reusable element interactions |
| Flow | src/flows/*.flow.ts | Multi-page workflows |
| Healing recipes | helpers/self-healing/recipes.ts | Fallback selectors for AI self-healing |
Generated code follows these conventions.
I.* directly—all browser interactions live in page objects or flows.expect() for value assertions, CodeceptJS methods for UI interactions.buildSitePath() for multisite support..as('Name') descriptions.After generation, verify the tests.
1pnpm e2e --grep "@your-tag"TypeScript definitions are auto-generated before each test run. To generate them manually for IDE IntelliSense, run:
1pnpm defThe end-to-end test suite includes full-page accessibility scanning using axe-core via @axe-core/playwright. Scans run in a real browser against the running storefront and catch issues that component-level Storybook a11y tests can’t detect, such as page composition, routing, layout, and responsive behavior issues.
wcag2a, wcag2aa, wcag21aa tags)pnpm a11y runs both passes sequentially via scripts/run-a11y.ts, starting with desktop and then enabling mobile with PLAYWRIGHT_MOBILE=true..retry(2) on the Feature. The a11yNoRetry plugin never retries confirmed a11y regressions (thrown as A11yBaselineError) because axe scans are deterministic and re-running a real violation always reproduces it.Start the storefront development server before running scans. From packages/template-retail-rsc-app, run pnpm dev.
Note
1# Run a11y scans against the running storefront
2pnpm a11y
3
4# Generate a Markdown report with ticket-friendly violation details
5pnpm a11y:report
6
7# Scan all pages and write existing or known a11y issues as the new baseline.
8# Typically useful for gating new a11y issues while the existing ones are being addressed.
9pnpm a11y:update-baselineEach scan prints a banner identifying the page, viewport, and WCAG standard.
1════════════════════════════════════════
2 A11Y SCAN: homepage | desktop
3 Standard: WCAG 2.1 AA (wcag2a, wcag2aa, wcag21aa)
4════════════════════════════════════════The test suite prints the severity legend once at the start of the run. On completion, each scan prints one of these results.
✓ PASS: homepage/desktop—5 violations (within baseline)—scan passed↓ homepage/desktop—violations decreased, run pnpm a11y:update-baseline—improvement detectedⓘ 2 moderate/minor rules exceeded baseline (not blocking—update with pnpm a11y:update-baseline)—moderate or minor counts increased; informational only, printed below the PASS linepnpm a11y:report runs all scans with result collection enabled and writes two files to a11y-report/.
report.md—Markdown summary table (page × viewport × severity counts) and per-violation detail with rule ID, description, axe-core help URL, and HTML snippets of affected elements. Use this to create accessibility tickets.report.html—Styled HTML version of the same report, intended for CI artifact upload and browser viewing.a11y-report/ is gitignored and treated as a generated artifact. Generate it locally when needed.
1pnpm a11y:report
2# Writes a11y-report/report.md and a11y-report/report.htmlThe test suite stores the baseline in a11y-baseline.json at the package root. Each entry maps a <pageKey>/<viewport> key to a Record<ruleId, nodeCount>.
1{
2 "homepage/desktop": { "color-contrast": 3, "image-alt": 1 },
3 "homepage/mobile": { "color-contrast": 2 },
4 "login/desktop": {}
5}On every test run, the spec compares the current axe output against the baseline.
Ratchet-down workflow: After fixing a known issue, update the baseline to lock in the improvement.
1pnpm a11y:update-baseline
2# Review the diff in a11y-baseline.json, then commit it
3git add a11y-baseline.json
4git commit -m "chore: ratchet down a11y baseline after fixing color-contrast on homepage"Initial setup for new pages: After adding a new page, run pnpm a11y:update-baseline. The command creates baseline entries automatically and populates them with current violation counts. Commit the result.
pnpm a11y always runs both viewport passes. To target a single viewport, invoke the test runner directly.
1# Desktop only
2tsx src/scripts/cli/test-runner.ts --grep @a11y
3
4# Mobile only (Pixel 7 emulation)
5PLAYWRIGHT_MOBILE=true tsx src/scripts/cli/test-runner.ts --grep @a11ypnpm e2e run --multiple desktop --grep "@a11y" doesn’t work. CodeceptJS run-multiple doesn’t forward --grep to its workers, so all tests run instead of just the a11y suite.
Note
Add a Scenario to src/specs/core/accessibility.spec.ts. Use this pattern as a starting point.
1Scenario("My New Page accessibility", async () => {
2 myPage.navigate();
3 await scanAndAssert("my-new-page");
4})
5 .tag("@a11y")
6 .tag("@my-new-page");Run pnpm a11y:update-baseline. The command creates baseline entries for the new page automatically.
Review the diff in a11y-baseline.json, then commit it.
axe-core reports violations with four impact levels.
| Level | Meaning |
|---|---|
critical | Blocks access entirely for users with disabilities |
serious | Creates significant barriers; fix quickly |
moderate | Creates difficulty for users with disabilities. Workarounds sometimes exist. |
minor | Low impact; fix when convenient |
Severity appears in these places in test output.
rule-id [impact]: N violations so you can assess priority at a glance.This table describes the environment variables for the a11y suite.
| Variable | Values | Description |
|---|---|---|
BASE_URL | URL | Storefront URL to scan. Defaults to http://localhost:5173. |
PLAYWRIGHT_MOBILE | true | Enables Pixel 7 emulation. pnpm a11y sets this automatically for the mobile pass. Use it directly to run a single mobile pass. |
A11Y_UPDATE_BASELINE | true | Writes current violation counts to a11y-baseline.json at the package root instead of asserting. pnpm a11y:update-baseline sets this automatically. |
A11Y_COLLECT_RESULTS | true | Writes scan results to a11y-report/data/ for offline report generation. pnpm a11y:report sets this automatically. |
A11y scans run as a parallel job alongside the core E2E suite on every PR, merge group event, and push to main or release-* branches. Both jobs share the same MRT deployment, so there’s no extra deploy cost.
.github/workflows/e2e-core-pr.yml.github/workflows/e2e-pr-runner.yml—the run_a11y job handles the scan, reporting, and artifact upload.run_a11y job is gated on the ENABLE_A11Y_CI repository variable. Set it to false to disable a11y CI globally without modifying any workflow file.pnpm a11y:report --no-ai—runs scans in collect mode and generates both a11y-report/report.md and a11y-report/report.html.a11y-report/report.md to the GitHub Actions job summary after each run, so you can view violation details directly in the Actions UI without downloading anything.a11y-report/report.html as a CI artifact (a11y-report-<run-id>) after each run. Download it from the Actions run summary to view violation details in a browser without cloning the branch.TypeScript errors about missing page objects
Regenerate definitions.
1pnpm defTests fail with “Element not found”
Enable AI self-healing.
1pnpm e2e --ai --grep "@failing-test"Local dev server won’t start
Check that .env exists at the project root and contains valid B2C Commerce credentials.
Port 5173 is already in use
1lsof -ti:5173 | xargs killAI features aren’t working
Verify that ANTHROPIC_API_KEY is set in .env.
1cat .env | grep ANTHROPICRemote tests fail: “BASE_URL required”
Set BASE_URL before running the command.
1BASE_URL=https://your-site.com pnpm e2e --mode=remote