如何在黄瓜范围报告中添加文本文件



我正在生成黄瓜范围报告,并将屏幕截图附加到结果,但现在我想将文本文件添加到输出文件中,可以吗? 如果是,请告诉我该怎么做。

创建并添加指向文本文件的链接:

test.info("<a href='path/text-file.txt'>click to view text</a>");

是否要随报告一起添加文本?如果是这样,只需添加要提供的文本即可this.attach()

例如: -this.attach('Hello');

After(function (scenarioResult) {
if(scenarioResult.isFailed()){
try {
let failedStep = '';
scenarioResult.stepResults.map((stepResult) => {
if(stepResult.status === Status.FAILED){
failedStep = stepResult.step.name;
}
});
this.scenario.attach(JSON.stringify(report, ["name", "age"], 't'));
//where name and age are keys in the json report
return this.attach('Failed scenario is ' + scenarioResult.scenario.name + ' - ' + failedStep);
}
catch (error) {
console.log(error);
}
}
});

最新更新