E2E testing
StartupJS uses Playwright for end-to-end tests. The CLI provides helpers to generate and run tests with the app already running.
Install Playwright
Generate tests with the Playwright codegen
This command builds the app, starts it, and opens Playwright's code generator. See all codegen flags here: https://playwright.dev/docs/codegen#running-codegen
Run tests
This command also builds and starts the app before running tests. See all test CLI options here: https://playwright.dev/docs/test-cli
Working with DB snapshots
If your app uses MongoDB, snapshots help you keep tests deterministic.
- Set a snapshot path:
- Start the app and create a snapshot for tests.
- Copy the snapshot into your test folder.
Generate tests using the snapshot:
Run tests using the snapshot:
CI integration
For a GitHub Actions example, see: https://github.com/startupjs/startupjs/blob/master/.github/workflows/run-tests.yaml
Resources
- Playwright docs: https://playwright.dev/docs/intro
- StartupJS backend flags: https://github.com/startupjs/startupjs/tree/master/packages/backend