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"
}
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"
}
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.
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
@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.
Most helpful comment
@Bkucera @jennifer-shehane is there any way using attachments in the report file? (junit) was anything added since this issue was opened?