当至少一个 Cypress 测试失败时在 AWS CodeBuild 中获取 "COMMAND_EXECUTION_ERROR ... Reason: exit status 1"

Getting "COMMAND_EXECUTION_ERROR ... Reason: exit status 1" in AWS CodeBuild when at least one Cypress test has failed

我有一个 AWS CodeBuild 项目,用于使用 Cypress.io 框架每晚执行自动化测试用例。每当至少有一个失败的测试用例时,我会在构建日志中收到以下错误:

[Container] 2022/03/15 14:18:22 Command did not exit successfully npm run cypress:run exit status 1
[Container] 2022/03/15 14:18:22 Phase complete: BUILD State: FAILED
[Container] 2022/03/15 14:18:22 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm run cypress:run. Reason: exit status 1

这是自定义脚本的样子:

"cypress:run": "npx cypress run --config-file custom-config.json",

这是我在自定义 config.json 文件中设置的内容:

{
  "$schema": "https://raw.githubusercontent.com/cypress-io/cypress/develop/cli/schema/cypress.schema.json",
  "viewportWidth": 1920,
  "viewportHeight": 1080,
  "defaultCommandTimeout": 30000,
  "requestTimeout": 30000,
  "numTestsKeptInMemory": 0,
  "trashAssetsBeforeRuns": false,
  "video": false,
  "env": {
    "coverage": false
  }
}

有人知道是什么原因造成的吗?

我认为您的问题已经有了答案“只要有至少一个失败的测试用例,我就会在构建日志中收到以下错误”。

在文档 here 中,您可以找到这两行:

“如果有任何测试失败,退出代码将匹配失败的测试数。”

“如果赛普拉斯由于某种原因无法 运行(例如,如果未找到规范文件),则退出代码将为 1。”