Skip to content
  • Sponsor codeceptjs/CodeceptJS

  • Notifications You must be signed in to change notification settings
  • Fork 736

fix: mochawesome helper with unique screenshots #4959

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

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

Lando1n
Copy link

@Lando1n Lando1n commented Apr 11, 2025

Motivation/Description of the PR

Screenshots started to fail to link when using the uniqueScreenshotName: true value on the Mochawesome helper.

This is due to the uuid suffix being added with a different method than before. Instead of re-implementing the same _getUUID function, it was moved into the testToFileName function with option unique.

Applicable helpers:

  • Playwright`
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe
  • Mochawesome

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@kobenguyent
Copy link
Collaborator

Could you please verify if the screenshot works correctly in reports? There was a previous issue with a broken screenshot link in reports, so it would be helpful to have a check. Thank you.

The fix was:
#4889

@Lando1n
Copy link
Author

Lando1n commented Apr 12, 2025

@kobenguyent - correct, it's now working for unique and non-unique screenshots.

Report:
image
With output directory like:
image

@kobenguyent
Copy link
Collaborator

@Lando1n may you think we could add some UTs for those changes in https://github.com/codeceptjs/CodeceptJS/blob/3.x/test/unit/plugin/screenshotOnFail_test.js

@Lando1n
Copy link
Author

Lando1n commented Apr 15, 2025

@Lando1n may you think we could add some UTs for those changes in https://github.com/codeceptjs/CodeceptJS/blob/3.x/test/unit/plugin/screenshotOnFail_test.js

For sure, will add.

@Lando1n
Copy link
Author

Lando1n commented Apr 16, 2025

@kobenguyent - added some tests, but they were reliant on a small Mochawesome helper modification in order to properly mock.

@Lando1n
Copy link
Author

Lando1n commented Apr 16, 2025

@kobenguyent - any idea why mochawesome isn't a dependency already? Seeing that test failure.

@kobenguyent
Copy link
Collaborator

@kobenguyent - any idea why mochawesome isn't a dependency already? Seeing that test failure.

I guess we shall keep this mochawesome as dev-deps right @DavertMik ?

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

test/unit/plugin/screenshotOnFail_test.js:137

  • Consider adding additional test cases that cover a broader range of configuration options and edge cases for unique screenshot naming to ensure consistent behavior across different scenarios.
// TODO: write more tests for different options

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

Successfully merging this pull request may close these issues.

None yet

2 participants