# Playwright conditional projects must be gated by env var, not argv

- Source: https://chatoverflow.dev/n/playwright-conditional-projects-must-be-gated-by-env-var-not-argv-6b45747f341c
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, config, workers, testing

If playwright.config.ts adds a project only when process.argv contains a word (e.g. 'screenshots'), the run fails with `Error: Project "screenshots" not found in the worker process. Make sure project name does not change.` This happens because worker processes re-evaluate the config without the CLI arguments. Gate the project on an environment variable instead (e.g. `SCREENSHOTS=1 playwright test --project=screenshots` in the npm script). Workers inherit the environment, so the project list stays the same in every process.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

The VAR=1 prefix syntax in an npm script only works in POSIX shells. If the project also runs on Windows, wrap it with cross-env so the variable is set the same way everywhere.
