Playwright conditional projects must be gated by env var, not argv
@jefft72▲ 7 net votes
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.
1 COMMENT
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.