Skip to content

Testing and quality gates

CommandDoes
npm run devBuild the engine once, then start the theme dev server (Turbopack).
npm run dev:engineRebuild the engine on change. Run it beside npm run dev when editing packages/engine: the theme reads the engine’s build output, not its source.
npm run buildProduction build of the theme.
npm run build -w @magenxcommerce/engineBuild the engine. Needed before a theme build, npm test, or a publish.
npm run startRun the production build.
npm run lintESLint over engine and theme.
npm run type-checkStrict TypeScript over both workspaces, app and test projects.
npm testVitest unit suites.
npm run test:coverageThe same with V8 coverage and per-file thresholds.
npm run eval:assistantLive evals for the shopper assistant against a fake store. Needs ANTHROPIC_API_KEY; not part of npm test. See the assistant guide.
npm run bundle-budgetFirst-load JavaScript per route against the committed budget.
npm run check:engine-packEvery engine import the theme uses resolves to a file in the engine’s npm package.
npm run check:engine-esmEvery exported engine module loads under plain Node ESM.
npm run check:overridessrc/custom/ overrides still match the upstream files they copied.
npm run sync:storesRefresh the store-view snapshot from Magento.
npm run formatPrettier over the monorepo.

Vitest runs two projects (vitest.config.ts):

  • node: pure logic. The /api/graphql allowlist and Turnstile, checkout helpers (addresses, payment redirect checks, Stripe amounts), the UCP and ACP surfaces, engine money math and HTML sanitising, and the schema drift test that checks every engine query against the companion modules’ schemas.
  • dom: React under jsdom with Testing Library: the cart, wishlist and auth contexts, the checkout step components (fields, payment and review steps, the Stripe and Mollie card forms), the order confirmation and Mollie return pages, and storefront components such as the product card, header navigation and the assistant panel.

Build the engine before npm test: the tests import its build output.

Coverage has no global threshold on purpose: one number over the whole codebase is either arbitrary or invites filler tests. vitest.config.ts sets per-file thresholds on the code every order passes through (the three contexts, checkout helpers, the order confirmation page, the proxy allowlist and Turnstile). Raise them when a suite covers more; never lower one to pass a PR.

npm run bundle-budget measures the gzipped first-load JavaScript of every prerendered route against scripts/bundle-budget.json, with 3% tolerance. It keeps the performance structure (deferred cart start-up, lazily loaded payment forms) from eroding unnoticed. Record an intended increase with node scripts/bundle-budget.mjs --update, so it shows up as a reviewable diff.

Every pull request runs, in order:

Engine build

Package shape

Node ESM load

Override drift

Theme overrides match root

Type-check

Lint

Tests + coverage

next build

Bundle budget

The override drift check runs early on purpose: it is a few file hashes, and a stale override makes every slower step after it wasted. Changes that only touch docs/ skip this gate and run the docs build instead.

tests/load/browse-browser.js is a k6 script, run by hand. A real headless Chromium walks home, category, product and search pages. It measures JavaScript, sub-resources, the browser cache on repeat views, and Core Web Vitals. See tests/load/README.md for how to run it.

  • End-to-end browser tests. They need a staging backend.
  • The checkout page itself. The step components have tests, but checkout/page.tsx, which wires the steps together, does not. Nor do the shipping step, address fields, pickup selector and order summary.
  • PHPUnit for most companion modules. A few modules, such as Cron Manager, have PHPUnit suites in their own repositories and run them in their own CI. Most have none, and the storefront’s PR gate runs none of them.
  • Pre-commit hooks. Lint, type-check and tests run only in the PR gate.