运行 Cypress 测试时,我希望始终返回退出代码 0。我在发布部署后运行这些测试,因此当它返回非零退出代码时,测试详细信息不会报告给发布摘要。许多测试运行器都有一个配置选项,可以在错误与否时失败,因此我正在寻找该选项。还没有看到这样的东西,所以请指点我。如果它不存在,我将打开一个功能请求。

谢谢!

最佳答案

试试这个:

// likely want to do this in a support file
// so it's applied to all spec files
// cypress/support/index.js

Cypress.on('uncaught:exception', (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false
})

/api/events/catalog-of-events.html#Uncaught-Exceptions

关于cypress - 总是返回 0 退出代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50109337/

10-12 03:47