[英]Perform custom actions on Cypress test retry
I am using retries in my Cypress test.我在赛普拉斯测试中使用重试。 Every time a test is retried, I want to perform an action (eg log details about the failure in a file).
每次重试测试时,我都想执行一个操作(例如,在文件中记录有关失败的详细信息)。
I thought the command:retry
from the catalog of events might be useful, but I am not sure what does the parameter mean and how can I use it.我认为
command:retry
事件目录中的重试可能有用,但我不确定该参数是什么意思以及如何使用它。
There is a cyclope plugin that may be covering what you are wanting to do with test failures.有一个cyclope插件可能涵盖了您想要对测试失败执行的操作。 This plugin includes a utilty function
savePageIfTestFailed
, which you can call in an afterEach()
inside your support/index.js
file.该插件包含一个实用工具 function
savePageIfTestFailed
,您可以在support/index.js
文件中的afterEach()
中调用它。
You may find command:retry
is a bit too granular, try the on fail event.你可能会发现
command:retry
有点太细化了,试试on fail事件。
Cypress.on('fail', (error, runnable) => {
debugger
// take a look at the parameters
console.log('error', error.message)
console.log('runnable', runnable)
// for example
let currentTest = runnable.ctx.currentTest
let title = runnable.title
throw error // throw error to have test still fail
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.