LironEr / cypress-mochawesome-reporter

Zero config Mochawesome reporter for Cypress with screenshots and videos
MIT License
163 stars 51 forks source link

onAfterScreenshot only work after a (non-failure) screenshot is taken #53

Closed jk4235 closed 2 years ago

jk4235 commented 2 years ago

Environment

- OS: Win 10
- Node: 12.17.0
- cypress-mochawesome-reporter: 2.3.0
- cypress: 7.5

What happened?

I found onAfterScreenshot only work after a non-failure screenshot is taken

so on v2.3.0, the reporter will not handle the screenshot which is taken by Cypress automatically when there is a failure

the function saveScreenshotReference will not run

// lib/enhanceReport.js attachScreenshotsToTestContext

const screenshotsContextIndex = parsedContext.findIndex(
    (c) => typeof c === 'object' && c.value && c.title === 'cypress-mochawesome-reporter-screenshots' // ← this will not work
);

Config file

"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
  "saveJson": true,
  "embeddedScreenshots": true
},

Relevant log output

No response

Anything else?

No response

jk4235 commented 2 years ago

I lock version to 2.2.1 for now

LironEr commented 2 years ago

I just ran one the of examples and I removed all cy.screenshot(), meaning only failed screenshots were taken. All worked as expected

If you still have that issue please provide a repo with a way to reproduce this issue

jk4235 commented 2 years ago

Thanks, I found the reason. My team member write a plugin that overwrite the onAfterScreenshot function, so the reporter doesn't work

I fix that problem.

Thanks!