'How to set environment variable to run webdriverIO script
I am running my webdriverIO test cases using command npx wdio run .\wdio.conf.js --spec .\test\intel.test.js
Now I want to pass environment variable for the same like ENV=qa
If I run command like this ENV=qa npx wdio run .\wdio.conf.js --spec .\test\intel.test.js Getting error:
ENV=qa : The term 'ENV=qa' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
- ENV=qa npx wdio run .\wdio.conf.js --spec .\test\intel.test.js
is there any way to set environment variable when we are using npx to run test cases?
Solution 1:[1]
Checkout dotenv package -> https://www.npmjs.com/package/dotenv and read this: https://nodejs.dev/learn/how-to-read-environment-variables-from-nodejs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gencho Kerkeniakov |
