我的测试文件中有以下内容。我正在尝试在我的脚本上使用环境变量,然后通过命令行发送值。
const MYURL = process.env.URL;
console.log(MYURL)
在我运行以下命令时的命令行中:
URL=Test.com npx playwright test
我收到一条错误消息:
The term ‘URL=Test.com’ is not recognized as the name of the cmdlet..etc.
我的测试文件中有以下内容。我正在尝试在我的脚本上使用环境变量,然后通过命令行发送值。
const MYURL = process.env.URL;
console.log(MYURL)
在我运行以下命令时的命令行中:
URL=Test.com npx playwright test
我收到一条错误消息:
The term ‘URL=Test.com’ is not recognized as the name of the cmdlet..etc.
因为您在 Powershell 中使用 bash 语法。Powershell 没有设置 env 变量var=value
,所以这种语法不起作用。
您可能需要阅读类似的内容来找出 Powershell 的正确语法。