赛普拉斯 BDD html 报告失败步骤的屏幕截图

Cypress BDD html report with screenshot for failed step

我想在 html 报告中附上我在 cypress 中的 BDD 测试失败步骤的屏幕截图。

我正在使用“multiple-cucumber-html-reporter”,我能够生成所有测试用例的 BDD 报告。

下面是我生成 html 报告的 .js 文件:

const report = require("multiple-cucumber-html-reporter");
report.generate({
jsonDir: "cypress/reports",  // ** Path of .json file **//
reportPath: "./cypress/reports/cucumber-htmlreport.html",
metadata: {
browser: {
name: "chrome",
version: "81",
},
device: "Local test machine",
platform: {
name: "mac",
version: "Catalina",
},
},
});

我知道在 cypress 的 BDD 插件中 html 报告我们不能像以前在 cucumber 中那样使用场景对象。

如何在此处添加截屏代码?

Cypress 本身会自动截取失败场景的屏幕截图。截图应该没有问题。参见:documentation But if you mean to attach the SS into html report, I suggest you to switch to Allure reporting tool for Cypress. see the detailed info and report here: allure reports