0๐
โ
I figured this out, by using cross-env
First I install cross-env
with npm i cross-env
In my package.json
, I modified like this
"scripts":{
"run:env" : "cross-env BROWSER=\"edge\" npm run cy:run"
"cy:run" : "cross-env-shell cypress run --browser=$BROWSER"
}
Then I run npm run run:env
Everything works now.
The process.env.BROWSER is still usable even I deleted the .env file
0๐
You need two dashes for the full "browser" option
"scripts":{
"cy:run" : "cypress run --browser %BROWSER%"
}
or one dash for shortcut "-b"
"scripts":{
"cy:run" : "cypress run -b %BROWSER%"
}
Source:stackexchange.com