我正在使用 cypress-cucumber-preprocessor 创建一些带有 cypress 的 cucumber 测试。问题是我只知道如何创建 JSON 或 JUnit 格式的报告。但我需要它们采用 cucumber 格式。就像在 Java 中完成的一样。
我找到了这个链接 https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/issues/79但没有人提出解决方案。
有人有自定义报告器可以创建类似 cucumber 的报告吗?或者知道何时会实现此功能?
最佳答案
按照步骤配置报告:
在
package.json
中导入库:- marge(用于合并 mocha 生成的文件)
- mocha(为模式 mocha 生成 json)
- mochawesome(为模式 mocha 生成 json)
- shelljs(它将用于 Node JS 能够与终端交互)
在
cypress.json
中配置:
...
"screenshotsFolder": "screenshots",
"reporter": "mochawesome",
"reporterOptions": {
"overwrite": false,
"html": false,
"json": true
}
...
在文件夹
report/
中用 code 创建文件index.js
.运行测试并执行命令
node report/index.js
。
按照教程配置截图:https://github.com/cypress-io/cypress/issues/3654
index.js 代码是基于 Google 的其他脚本(查看引用),这个 Github 脚本是我为 friend 做的。
引用资料:
- 我 friend 的 repo :https://github.com/vcamposs/easy-front-end-component-test-with-cypress
- Credits 脚本合并文件 cypress:https://github.com/testdrivenio/cypress-mochawesome-s3/blob/master/scripts/combine.js
对不起,我不会说英语...
关于javascript - 如何将 cucumber 报告添加到 Cypress ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56145586/