cypress
cypress copied to clipboard
Attachment path injected into the test object is not passed to the reporter
Current behavior:
New feature in mocha-junit-reporter allows for an attachment path to be included in the report output file. To achieve this the attachment path is injected into the test object:
it ('should include attachment', function () {
this.test.attachments = ['/absolut/path/to/file.png'];
});
(as described here: https://github.com/michaelleeallen/mocha-junit-reporter#attachments)
Currently Cypress does not pass the injected attachment in the test object passed to the reporter:
{
"title": "should include attachment",
"pending": false,
"type": "test",
"body": "function () {\n this.test.attachments = ['/absolut/path/to/file.png'];\n}",
"duration": 45,
"state": "passed",
"parent": "#<Suite>",
"id": "r2",
"wallClockStartedAt": "2019-01-16T14:36:45.039Z",
"timings": {
"lifecycle": 40,
"test": {
"fnDuration": 1,
"afterFnDuration": 3
}
},
"speed": "medium"
}
Desired behavior:
Cypress passes the injected attachment in the test object passed to the reporter:
{
"title": "should include attachment",
"attachments": '/absolut/path/to/file.png',
"pending": false,
"type": "test",
"body": "function () {\n this.test.attachments = ['/absolut/path/to/file.png'];\n}",
"duration": 45,
"state": "passed",
"parent": "#<Suite>",
"id": "r2",
"wallClockStartedAt": "2019-01-16T14:36:45.039Z",
"timings": {
"lifecycle": 40,
"test": {
"fnDuration": 1,
"afterFnDuration": 3
}
},
"speed": "medium"
}
Steps to reproduce: (app code and test code)
Run test:
it ('should include attachment', function () {
this.test.attachments = ['/absolut/path/to/file.png'];
});
And view the object that is passed to the reporter.
Versions
cypress: 3.1.4
@bkosse since we expect the test context to adhere to a strict schema, we explicitly construct the final context before passing it to reporters, picking only the values we expect off of the mocha context.
However, we are working on a feature to allow you to attach arbitrary data onto a ctx
object that can be passed onto reporters, and should be in an issue soon
https://github.com/cypress-io/cypress/blob/4b368830faca8794859abd8972f0c67a5bdd5839/packages/server/lib/reporter.coffee#L66
@Bkucera @jennifer-shehane is there any way using attachments in the report file? (junit) was anything added since this issue was opened?
This issue is still in the 'proposal' stage, which means no work has been done on this issue as of today, so we do not have an estimate on when this will be delivered.
Any progress?
Is there anything the community can do to help get this implemented? I'd love this in our CI/CD.
GitLab just added support for showing JUnit screenshot attachments in merge requests. Hopefully that encourages more interest in this proposed feature.
Hi, How's is the progress on this issue. We would really like to see it happen... Cheers!
Just another comment to promote this request. Gitlab CI CD supports Junit format reports and it would be amazing to see screenshot attachments
Any movement on this? I'm also running cypress tests in gitlab CICD and would love to include screenshots in my JUnit reports.
Same here, trying to attach screenshots to the Test object provided to mocha-junit-reporter but impossible to configure attachments as it is described here:
Still no progress here?
Would be really handy.
Hello Guys, tired of waiting I just create this library for this purpose. Is able to attach screenshots into the report and import them into xray
https://www.npmjs.com/package/cypress-xray-junit-reporter
Its the first version, further development requests are appreciated.
This feature would be very useful. Azure DevOps recently made some improvements to the Publish Test Results task in Azure Pipelines. This task now supports file attachments when publishing test results from a JUnit report.
Any progress on this? Still an issue in 13.10.0