【发布时间】:2021-11-29 20:17:10
【问题描述】:
在将 testcafe 与 azure 发布管道集成时遇到错误。我已经尝试在构建管道中进行集成,它工作得非常好,但是它在发布管道中抛出“[error]Cmd.exe exited with code '1'”。我不确定是什么原因。 我希望有人可以帮助我:)。
下面是错误输出:
2021-10-05T08:33:57.3911161Z ##[section]Starting: Run TestCafe Tests
2021-10-05T08:33:57.4071780Z ==============================================================================
2021-10-05T08:33:57.4072094Z Task : Command line
2021-10-05T08:33:57.4072399Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2021-10-05T08:33:57.4072748Z Version : 2.182.0
2021-10-05T08:33:57.4072963Z Author : Microsoft Corporation
2021-10-05T08:33:57.4073278Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2021-10-05T08:33:57.4073645Z ==============================================================================
2021-10-05T08:34:00.0399162Z Generating script.
2021-10-05T08:34:00.0499795Z Script contents:
2021-10-05T08:34:00.0506235Z npm test
2021-10-05T08:34:00.0884424Z ========================== Starting Command Output ===========================
2021-10-05T08:34:00.1148843Z ##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\1eb75b5b-b311-4988-ac2b-114310419f26.cmd""
2021-10-05T08:34:01.2607636Z npm ERR! missing script: test
2021-10-05T08:34:01.2933116Z
2021-10-05T08:34:01.2934273Z npm ERR! A complete log of this run can be found in:
2021-10-05T08:34:01.2934931Z npm ERR! C:\npm\cache\_logs\2021-10-05T08_34_01_256Z-debug.log
2021-10-05T08:34:01.4413461Z ##[error]Cmd.exe exited with code '1'.
2021-10-05T08:34:01.4946159Z ##[section]Finishing: Run TestCafe Tests
下面是我的 package.json:
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"scripts": {
"test": "testcafe chrome:headless Tests/NewTest.js --reporter spec,xunit:report.xml"
},
"devDependencies": {
"testcafe": "^1.16.0",
"testcafe-reporter-xunit": "^2.1.0"
}
}
谢谢。
【问题讨论】:
-
您能否确认您已按照guide 中的所有步骤操作?
-
是的,我按照用户指南中的步骤操作。我在构建管道和发布管道中都尝试过。但是只有 build pipeline 中的那个能完美运行,release pipeline 提示上述错误。
-
您如何确保在您的发布管道中 package.json 可用,您将需要执行测试?因为通常,在发布管道中,构建工件是输入,它不再包含 package.json 文件。 package.json 仅在构建阶段才需要。
-
我现在明白为什么它无法读取 package.json 了,非常感谢。我对 azure devops 和 testcafe 还是很陌生,是否有任何其他解决方案/建议可以将 testcafe 与发布管道集成?我一直在寻找解决方案,但仍然没有找到。
-
我已经按照您的建议解决了这个错误。非常感谢:)
标签: node.js azure-devops devexpress e2e-testing testcafe