Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Relative path instead of Absolute path for failed screenshot due to cypress-image-snapshot #388

Open
787681277 opened this issue Nov 22, 2022 · 0 comments

Comments

@787681277
Copy link

787681277 commented Nov 22, 2022

Describe the bug
A clear and concise description of what the bug is.

Cannot see failed screenshot in mochareports/report.html after run testing in pipeline

Because failed screenshot use Absolute path, and redundant path "/script" is displayed after run testing in pipeline:
"See diff for details: /scripts/cypress/snapshots/chrome/tab/tab.component.cy.ts/diff_output/activeIndex-1.diff.png"

Code Reproduce
Link to repo where the issue can reliably be reproduced:

//Inject cypress-image-snapshot diff images to Mochawesome reports
const addContext = require('mochawesome/addContext');
Cypress.on('test:after:run', (test, runnable) => {
if(test.state === 'failed') {
let screenshot;
screenshot = ${Cypress.config('screenshotsFolder')}/${Cypress.spec.name}/${runnable.parent.title} -- ${test.title} (failed).png;
if(test.err.message.includes('See diff')) {
// If the test failed due to cypress-image-snapshot the message will always be the same and the plugin gives you in the message the url of the path
screenshot = test.err.parsedStack[1].message.replace('See diff for details: ', '');
}
addContext({test}, {
title: 'Image',
value: screenshot
});
}
})

Expected behavior
A clear and concise description of what you expected to happen.

Use Relative path for failed screenshots due to cypress-image-snapshot , the failed screenshot can be seen after run testing in piepline

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Platform
  • mac
  • mochawesome version
  • mocha (or other test library) version
  • Node version
  • node 14.20.0

Screen Shot 2022-11-22 at 12 08 16

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant