e2e/README.md
The tests expects to find the below env variables. Either define it in your shell, or add it to the .env.local file in the repository root.
SANITY_E2E_SESSION_TOKEN: Before you get started with writing and running tests, you need to get hold of a token - either using your own Sanity user token (sanity debug --secrets will give you the CLI token provided you are logged in sanity login), or by creating a project API token using https://sanity.io/manage.SANITY_E2E_PROJECT_ID: Project ID of the studioSANITY_E2E_DATASET: Dataset name of the studioMake sure that the project that you are running in the e2e tests allows the origin of your local studio (this is default http://localhost:3339) in https://sanity.io/manage > your project > API > Add CORS origin
To run E2E tests run the following commands from the root of the project
Run all the tests
pnpm test:e2e
Run all tests in specific directory, it runs relative to the e2e/tests
pnpm test:e2e tests/default-layout
Run files that have my-spec or my-spec-2 in the file name
pnpm test:e2e my-spec my-spec-2
For help, run
pnpm test:e2e --help
Other useful helper commands
sanity devsanity build on E2E studiopnpm e2e:dev in another terminal firstsanity preview on E2E studio (preview server, requires a build)sanity build, then sanity preview on E2E studioFor more useful commands, see the Playwright Command Line documentation.
You can run your tests in your editor with the help of some useful editor plugins/extensions. For example, you can download Playwright Test for VSCode from Microsoft to show and run your tests in VSCode.