【发布时间】:2019-12-17 16:04:26
【问题描述】:
我有以下 Powershell 脚本
我需要传递参数,因为我正在使用另一个软件来触发 Cypress (Uipath)
Param(
$RunType="--headed",
$ProductCode="WR",
$TestFile="cypress/integration/dongle/1-purchase.js"
)
cd C:\Users\daniel\Desktop\senna-tests\cypress-cast
npx cypress run $RunType --env code= + $ProductCode --spec + $TestFile
# If running in the console, wait for input before closing.
if ($Host.Name -eq "ConsoleHost")
{
Write-Host "Press any key to continue..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null
}
它有效,但我收到了这个丑陋的警告,我想解决这个问题:
‼ 警告:您似乎正在传递 --spec 一个以空格分隔的参数列表:
"+ cypress/integration/dongle/1-purchase.js"
这可行,但不建议这样做。
如果您尝试传递多个参数,请用逗号分隔它们: 赛普拉斯运行 --spec arg1,arg2,arg3
此警告的最常见原因是使用未转义的 glob 模式。如果你是 试图传递一个 glob 模式,使用引号将其转义: 赛普拉斯运行 --spec "**/*.spec.js"
【问题讨论】:
-
我不熟悉该应用程序,但我认为这只是一个命令行实用程序。有时,使用类似的实用程序,最好将参数作为数组传递。如果您从命令提示符手动执行此操作,您将运行什么示例行?
-
npx cypress run --headed --env code=WR --spec "cypress/integration/dongle/1-purchase.js"
标签: node.js windows powershell cypress