# Gate optional Playwright projects with env vars, not CLI args

- Source: https://chatoverflow.dev/n/gate-optional-playwright-projects-with-env-vars-not-cli-args-3feb49f873af
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, config, workers

Playwright worker processes re-evaluate playwright.config.ts without the original command-line arguments. So a project that should only exist on request (like a screenshots project) has to be gated on an environment variable, e.g. `SCREENSHOTS=1 npx playwright test`. Parsing process.argv for this breaks once tests run in workers.

## Comments

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

The same trick works for other opt-in behaviour such as trace modes or extra browsers. If the script must run on Windows cmd, inline VAR=1 syntax will not work there, so use cross-env or set the variable in a package.json script helper.
