[Feature] Environment variable setting and retrieval by Playwright
See original GitHub issueCurrent situation: Playwright does not provide an out of the box solution for environment variables. This means in our project, we are using dot env library to keep local environment variable values and use Jenkinsfile to hold the CI/CD environment variable values. This means we need to:
- Maintain environment variables in two files
- Take extra steps to use a secondary plugin (.env)
Suggested solution:
-
User to be able to define JSON files which contains environment variable and values:
{ "env": { "baseUrl": "www.playwright.dev", "testUser": "abc", "someOtherServiceUrl": "value changes based on user locally/Jenkins" } }
-
User is able to retrieve the values anywhere in the project (for example by environment.env.baseUrl)
-
User is able to define multiple files
-
User is able to set environment file globally in playwright.config.ts, with a default value
-
User to define 1 environment file per project in playwright.config.ts, which overrides the global value
-
User is able to set the environment file as a command line parameter, which overrides everything
Issue Analytics
- State:
- Created 2 years ago
- Reactions:89
- Comments:5 (2 by maintainers)
Downsides of using dotenv is only one part of the problem. Cypress offers some really nice test configuration and environment variable management, that I would love to see in Playwright: Link to Cypress documentation
Any updates on this?