I need to execute some code after all tests run. I add this test on after hook. But this task needs the report to be created, but on after hook, the report is not created yet.
I also tried to use
on('run:end', () => {
console.log("gdfgfdsafkañjsdfjñaldfkjsñkasfdñlassfjdskafmjassd");
});
but it does nothing.
You can't, there is an open issue for that.
At the moment you can only leverage a package.json
post
hook. So, if you have a dedicated command in your package.json
file
"scripts": {
"cy:run": "cypress run"
}
you can add a postcy:run
script
"scripts": {
"cy:run": "cypress run",
"postcy:run": "<YOUR_COMMAND>"
}
I hope it helps you 😊
You can now listen to after:run
events in the plugins file:
on('after:run', (results) => { /* ... */ })
The event fires after the run.
See more info at After Run API
Be aware that the post
hook might not run when the tests fail. I'm currently using a global after
hook in support/index.ts
for running after all tests
I'm currently using a global after
hook in support/index.ts
after(() => {
// something here
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With