- Environment variables for settings that change between environments, such as the app URL.
- Fixtures for a known set of test data you reuse across tests.
- Generated data for values that must be unique on every run.
Read environment variables
Read settings fromprocess.env so the same test runs against dev, staging, or production.
tests/home.test.mjs
.env file in your project root automatically, so you can also keep local values there:
.env
Reuse test data with fixtures
Put shared test data in its own module and import it wherever you need it.tests/fixtures/usernames.js
it.for() to run the same test once per fixture. Unlike it.each(), it.for() passes the test context as the second argument, which TestDriver(context) needs.
tests/login.test.mjs
Generate unique data
When a test creates records, such as new accounts, generate fresh values on every run so they don’t collide with earlier runs. Faker is a common choice:tests/signup.test.mjs
Keep values out of descriptions
Pass changing values totype(), not to find().
The cache matches find() descriptions exactly. A description that contains a generated value misses the cache on every run:
Next steps
Use secrets
Keep passwords and tokens out of code and logs.
Reuse code
Share helpers like a login step across tests.
Run in CI/CD
Pass environment variables to tests in your pipeline.
Caching
Write descriptions that reuse cached locations.

