如何在每次运行柏树之前删除报告文件夹?
我将Cucumber HTML报告存储在Cucumber-HTML-Reports文件夹中,JSON文件存储在Cucumber-JSON文件夹下。现在,我要删除/清空这两个文件夹。我需要插入才能实现这一目标。
I am storing my cucumber html report under cucumber-html-reports folder and json files are storing under cucumber-json folder. Now I want delete/empty these two folders. I need a plug in to achieve this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的方法是添加一个NPM脚本来清理报告文件夹并在测试运行之前执行它。为此,赛普拉斯在其网站上有一个示例NPM脚本。 https://docs.cypress.io/guides/guides/guides/guides/guides/tooling/tooling/tooling/reporters# Command-Line-3
通常,CI/CD管道将在测试运行开始之前运行清理脚本。另外,您可以在插件文件中添加一点代码,以在测试运行之前执行NPM脚本。
一种hacky选项,在Cypress Config中有一个
trashassetsbeforeruns
选项(默认设置为true
)。它用于在测试运行之前清理下载,视频和屏幕截图文件夹。如果将记者结果映射到可能有效的这些目录之一,尽管我不能保证成功的成功,因为我还没有这样做。The correct way to do this is to add an npm script to clean up the report folder and execute it before the test run. Cypress has an example npm script on their website for this. https://docs.cypress.io/guides/tooling/reporters#Command-line-3
Usually, the CI/CD pipeline would run the clean up script before the test run kicks off. Alternatively, you could add a little bit of code to your plugins file to exec the npm script before the test run as well.
One sort of hacky option, there is a
trashAssetsBeforeRuns
option in the Cypress config (set totrue
by default). It's used to clean up the downloads, videos, and screenshots folders before a test run. If you map your reporter results to one of these directories that might work, although I can't guarantee success with it since I haven't done that.