我正在使用 mochawesome 进行柏树测试。
这是我的 cypress.json 文件
{
"viewportWidth": 1440,
"viewportHeight": 800,
"defaultCommandTimeout": 8000,
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/reports/mochawesome-report",
"reportFilename": "sample",
"overwrite": false,
"html": true,
"json": true
},
"env": {
"environment": "Stagging"
},
"screenshotsFolder": "cypress/reports/mochawesome-report/assets",
}
当我运行测试时,生成的报告名称为“sample.html”,这是预期的,因为我已将报告标题定义为 cypress.json 中的样本文件。
现在我想为每个基于测试套件名称生成的报告取一个唯一的名称。
所以我使用了 cypress 事件 'test:before:run
' 并在 cypress.json< 中设置了 reportFilename
/strong> 到每个测试执行前的测试套件名称,示例代码在下面
Cypress.on("test:before:run", (test, runnable) => {
console.log(Cypress.config("reporterOptions").reportFilename);
const suiteTitle = runnable.parent.title;
Cypress.config({
"reporterOptions":{
"reportFilename": suiteTitle
}
});
const reportFileName = Cypress.config("reporterOptions").reportFilename;
console.log(reportFileName);
});
我看到 reportFilename
已成功更改为配置文件中的测试套件名称
但我的报告仍保存为“sample.html”
为什么我的报告仍然保存为 sample.html ,而不是我的测试套件名称?
有人能帮我解决这个问题吗?
最佳答案
这不是问题,这需要对 moachawesome 代码库进行新的增强并寻求帮助
关于javascript - mochawesome 报告的名称未按预期保存(即使 cypress.json 中的 'reportFilename' 已更改),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58548378/