question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Environment variable setting and retrieval by Playwright

See original GitHub issue

Current 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:

  1. Maintain environment variables in two files
  2. 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:open
  • Created 2 years ago
  • Reactions:89
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
irharrier2commented, Oct 21, 2022
  1. Dotenv does not work with Jenkins, so I need to maintain two different set of env variables (one for dotenv and one in Jenkinsfile)
  2. I have to use a secondary plugin such as dotenv, which goes against the whole concept of Playwright being all in one pack

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

0reactions
iamlevikcommented, Dec 14, 2022

Any updates on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright Advanced Configuring - Sauce Labs Documentation
All values in your saucectl configuration support environment variable expansion. $var in config.yml will be replaced according to your shell's ...
Read more >
How to set environment variables like test ... - Stack Overflow
In Hooks BeforeAll function, reassign values from 'this' to the static variables created in the class. import { setWorldConstructor } from ' ...
Read more >
Execute in multiple environment | Playwright Tutorial - Part 80
Playwright Framework #2 | Execute in multiple environment | Playwright Tutorial - Part 80 ; # playwright global setup function to handle the ......
Read more >
Working with Environment Variables in PHP - Twilio
In this tutorial, you're going to learn how to set and retrieve environment variables in PHP, so that your applications can access all...
Read more >
Using Environment Variables in Go | by Wei-Meng Lee
Setting and Getting Environment Variables ... The Setenv function returns an error if it fails to create the environment variable. To retrieve the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found