Testing
Catalyst includes two kinds of tests:
- UI tests use Playwright to test components and verify workflows in the browser. They live in
tests/. - Unit tests use Vitest and live alongside the code they test, as
lib/**/*.spec.tsfiles.
Run all of the commands on this page from your project root, the directory that contains package.json.
If your project uses the older monorepo structure, run them from the core/ directory instead.
Set up the test environment
UI tests read your existing .env.local, plus a .env.test file for test-specific settings. Values in .env.test override those in .env.local.
-
Copy the example file:
-
In
.env.test, setPLAYWRIGHT_TEST_BASE_URLto the storefront the tests should run against. It defaults tohttp://localhost:3000. To test a deployed storefront, set it to that storefront’s URL. -
Optionally, set the other variables in
.env.test. The comments in.env.test.exampledescribe each one:
Run the UI tests
Run the tests against a production build so they include your latest changes. Build and start the storefront first:
Then, in another terminal, run all UI tests in Chromium:
To run a specific test file:
Catalyst’s Playwright config defines two projects:
tests-chromiumruns every test except mobile tests.tests-webkit-mobileruns only*.mobile.spec.tsfiles, on a mobile WebKit device.
To run a single test by name, add -g "<test name>". For more options, see the Playwright CLI documentation.
Run the unit tests
This runs Vitest against the lib/**/*.spec.ts files. Playwright specs in tests/ aren’t included.