You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Is there a way to add screenshot to JUnit report as attachment? #1502
I'd like to generate a JUnit report for my tests, and include a screenshot, which is automatically saved by codeceptjs on fail.
Searching didn't give any results. But maybe there is a simple way to achieve this though?
This is a part of my config describing reporter options:
in the end, it will work when everything is changed.
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesname="Mocha Tests"time="0.989"tests="1"failures="1">
<testsuitename="Root Suite"timestamp="2019-03-26T11:05:48"tests="0"failures="0"time="0">
</testsuite>
<testsuitename="@test"timestamp="2019-03-26T11:05:48"tests="1"file="/Users/thanhnguyen/Desktop/ucb-client/test/codeceptjs/tests/smokeCheck/test.js"failures="1"time="0.989">
<testcasename="@test: test"time="0.989"classname="test">
<system-out>[[ATTACHMENT|/Users/thanhnguyen/Desktop/ucb-client/test/codeceptjs/output/test_1553598349.failed.png]]</system-out>
<failuremessage="expected web application to include "sbc""type="Error"><![CDATA[expected web application to include "sbc"Scenario Steps:- I.see("sbc") at Test.Scenario (test/codeceptjs/tests/smokeCheck/test.js:5:7)- I.amOnPage("https://google.com") at Test.Scenario (test/codeceptjs/tests/smokeCheck/test.js:4:7)]]></failure>
</testcase>
</testsuite>
</testsuites>
I have finally tried it just recently and it didn't work for me at first.
Then I figured out that adding attachments: true line is insufficient and it also needs to be duplicated in the options object, like this:
mocha-junit-reporter: {
stdout: "./output/console.log",
options: {
mochaFile: "./output/result.xml",
attachments: true //<-- also here
},
attachments: true //<-- here as described
}
With both lines it works as expected.
Probably you need to do something about it :)
Activity
kobenguyent commentedon Mar 26, 2019
@iljao well, I took some times to look at this, there are several things to make this works:
The current npm of this repo
https://github.com/michaelleeallen/mocha-junit-reporteris not updated, which means attachments will not work -> michaelleeallen/mocha-junit-reporter@36ea8b8#diff-168726dbe96b3ce427e7fedce31bb0bcR23 -> to solve this, you need either wait for the author to publish the latest version or clone it ;)We need also to turn it on from
codeceptjsside, the config should be like thisand also there is a change in the core of the this file
screenshotOnFail.jskobenguyent commentedon Mar 26, 2019
in the end, it will work when everything is changed.
yogainalift commentedon Apr 10, 2019
The PR is merged for mocha-junit-reporter. Is there a possibility that this feature request gets in?
iljao commentedon May 20, 2019
Hi again!
Thanks for adding this feature!
I have finally tried it just recently and it didn't work for me at first.
Then I figured out that adding
attachments: trueline is insufficient and it also needs to be duplicated in theoptionsobject, like this:With both lines it works as expected.
Probably you need to do something about it :)