'Has anyone successed to include screenshots in mocha-junit-reporter XML files with Cucumber preprocessor?

I'm trying to generate XML Junit results to be included in Gitlab pipelines results.

So far, it is getting smoothly : I have every XML files generated, and they display as I want to in the pipeline.

However, once I try to embed the screenshots taken during the scenarios, I cannot make it work.

I started here : https://www.npmjs.com/package/mocha-junit-reporter#attachments

So, I generated my cypress.json like this :

"mochaJunitReporterReporterOptions": {
        "mochaFile": "cypress/reports/junit/results-[hash].xml",
        "attachments": true
    }

As it seems to not be automatic this, I added a beforeEach hook, with:

this.test.attachments = ['cypress/screenshots/scenario/scenario.feature/test-scr.png'];

If I try to set this line inside a test, and not in the hood, I have an error saying:

Cannot read properties of undefined (reading 'test')"

In this folder, this file exists, but I'm not sure if I am starting at the good folder level to include it (anyway, I tried several possibilities, never got it to work).

I never get to have this new tag :

<system-out>[[ATTACHMENT|path/to/file]]</system-out>

I get the feeling that there is kind of a different way of working with the cucumber preprocessor, as we don't write between describe and it anymore, but I have no proof o that.

What am I missing ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source