英文:
Cypress Mochawesome report showing file twice
问题
我正在运行 Cypress 12.13.0,搭配 mochawesome-report-generator 6.2.0、mochawesome-merge 4.3.0 和 mochawesome 7.1.3,尽管我在几个 Cypress 版本上都遇到了这个问题。
我正在使用 Bamboo 运行一个 PowerShell 脚本来运行所有文件并生成报告。脚本如下:
npx cypress run --spec 'cypress/e2e/features/**/*'
npx mochawesome-merge cypress/results/json/**/*.json -o combined-mochawesome.json
npx marge combined-mochawesome.json
根据报告,似乎 Cypress 会重新运行整个文件,该文件包含多个测试。有人知道为什么会这样吗?Cypress 配置文件中没有设置重试。
Bamboo 的日志中并未显示额外的运行,只显示了一次文件的运行。
英文:
I'm running Cypress 12.13.0 with mochawesome-report-generator 6.2.0, mochawesome-merge 4.3.0 and mochawesome 7.1.3, although I've had this problem for a few versions of Cypress.
I'm using bamboo to run a powershell script to run all of the files and generate the reports. It looks like:
npx cypress run --spec 'cypress/e2e/features/**/*'
npx mochawesome-merge cypress/results/json/**.json -o combined-mochawesome.json
npx marge combined-mochawesome.json
It appears cypress is re running an entire file, which contains multiple tests, according to the report at the end. Anybody know why that is? The cypress config file doesn't have retries set.
The log from bamboo doesn't show an additional run, it only shows 1 run of the file.
答案1
得分: 3
以下是您要翻译的内容:
"It looks like a report from a prior run is being picked up (only the last spec is repeated).
To be sure, add a 'trash-assets' hook before the run
const { defineConfig } = require('cypress')
const fs = require("fs");
const path = require("path");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('before:run', (details) => {
const resultsPath = path.resolve(__dirname, 'cypress/results')
const files = fs.readdirSync(resultsPath)
for (const file of files) {
fs.unlinkSync(path.resolve(resultsPath, file))
}
})
},
},
experimentalInteractiveRunEvents: true, // for open mode
})
```"
<details>
<summary>英文:</summary>
It looks like a report from a prior run is being picked up (only the last spec is repeated).
To be sure, add a "trash-assets" hook before the run
```js
const { defineConfig } = require('cypress')
const fs = require("fs");
const path = require("path");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('before:run', (details) => {
const resultsPath = path.resolve(__dirname, 'cypress/results')
const files = fs.readdirSync(resultsPath)
for (const file of files) {
fs.unlinkSync(path.reaolve(resultsPath, file)
}
})
},
},
experimentalInteractiveRunEvents: true, // for open mode
})
答案2
得分: 0
原来我们的代码库中有一个包含 JSON 文件的结果文件夹。这是意外造成的。删除了该文件和文件夹后,问题解决了,现在一切都正常工作。
英文:
Turns out that a results folder with a json file checked into our repository. This was done by accident. Removing the file and folder this problem has gone away and everything works as expected now.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论