alecmestroni / cypress-xray-junit-reporter

Npm module for cypress and xray
MIT License
0 stars 0 forks source link

Screenshots are not added to the report.xml #2

Open jelingi opened 2 months ago

jelingi commented 2 months ago

Hey,

we want to use the cypress-xray-junit-reporter. We installed the reporter and added it to the cypress.config.js. If we run the tests with npx cypress run , the reported is generated successfully with the property for the jira-testkey. Somehow our screenshots are not attached to the report. Below you find our configuration: Cypress.config.js reporter: 'cypress-xray-junit-reporter', reporterOptions: { mochaFile: './report/[suiteName].xml', useFullSuiteTitle: false, jenkinsMode: true, xrayMode: true, // if JiraKey are set correctly inside the test the XML report will contain the JiraKey value attachScreenshot: true, // if a test fails, the screenshot will be attached to the XML report and imported into xray } The path for the report is: cypress-example\report\Home Page.xml

And the path for the screenshots is: cypress-example\report\homePage.cy.js\Home Page -- should find an older post by loading more (failed).png

Can you help us with that problem ? Do you know any solution for that?

Kind regards Jelin Gießelmann

alecmestroni commented 2 months ago

Hey @jelingi,

Have you correctly added the configurations in the support/e2e.js file?

If yes, could you please provinde a git repo where i can reproduce the issue?

Thanks Alec

jelingi commented 2 months ago

Hey Alec,

thanks for your reply. You can check my repo here: https://github.com/jelingi/cypress-example I added the import in the e2e.js file. Somehow I recieve the error "test is not defined" (see attachment) image

Thanks for your help. Jelin

alecmestroni commented 2 months ago

Hello @jelingi,

Thank you for providing the repository.

However, I noticed that Cypress isn't being used correctly in your project. After installing Cypress on a fresh repository, you should run npx cypress open. This command will automatically generate the correct folder structure, including the e2e, fixtures, and support folders.

Additionally, in the newer versions of Cypress, it's highly recommended to use Cypress custom commands, instead of pages.

I've created a pull request that includes these fixes, along with a few adjustments to the project that I hope you'll find helpful. https://github.com/jelingi/cypress-example/pull/1

here just the edit to make the reporter work: https://github.com/alecmestroni/cypress-example/tree/push-no-custom-commands Here the branch with custom commands ajustments: https://github.com/alecmestroni/cypress-example/tree/main

With these changes, the reports should now generate correctly with the screenshots.

Feel free to reach out if you need anything else.

Best regards,

Alec