Add failed screenshot to test information for custom reporter
See original GitHub issueCurrent behavior:
When writing a custom reporter you have access to some information from the test, but no indication of the screenshot taken automatically on failure.
runner.on('test end', function(test) {
console.log(test);
});
Desired behavior:
the test object to have the screenshot path
runner.on('test end', function(test) {
console.log(test.screenshot);
// or
console.log(test.failedScreenshot);
});
Steps to reproduce: (app code and test code)
simple runner reporters/test.js
module.exports = function(runner, config) {
runner.on('test end', function(test) {
console.log('test done');
});
}
use in cypress.json
{
"reporter": "reporters/test.js"
}
Versions
Cypress 3.3.1
OS: Linux (Ubuntu)
Browser: Any
Workaround
You can access the files with fs
and path
no problem in the end
hook. This is less than ideal as you have to try and map file names to your failures
runner.on('end', function() {
//getFilePaths is a helper to list all files in a directory
console.log('end:', getFilePaths('cypress/screenshots'));
});
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:15 (1 by maintainers)
Top Results From Across the Web
How to add Screenshot in Extent Report for Failed Test Cases ...
How to add Screenshot in Extent Report for Failed Test Cases in Selenium:Learn:+ How to generate Extent Report +How to add screenshot for ......
Read more >Extent Reports - Screenshots of Failed Test Cases in Extent ...
Insert Screenshots of a Failed Test Cases in Extent Reports: In this post, we see how to add Screenshots in Extent Reports –...
Read more >How can I include a failure screenshot to the testNG report
Yes, you can include the link to your screenshot in testng report. ... Then you can find this link under the failed testcases...
Read more >How to add Screenshots to Jest report. | by Harry Hou - Medium
You know we cannot add any custom data to the test results. The only way is that we save all Info of the...
Read more >How to Attach Cypress Screenshots to the Mochawesome ...
In this article, we will look at how to add the failed test screenshot to the Mochawesome report and set a custom screen...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jennifer-shehane Yeah, have added screenshots to mochawesome using mapping filename approach and it was a long road of defining how screenshot names behave with special symbols (some are supported, other deleted) and after switch from 3.2 to 3.3 it has changed >< So it would be great to have it accessible inside test object.
@irfancharania Here is the one that works even if there are failures in any of the hooks as well.