Skip to content

Conversation

@mirao
Copy link
Contributor

@mirao mirao commented Nov 11, 2025

Motivation/Description of the PR

Fixed by Copilot Claude Sonnet 4.
I checked that the unit test should generate unique screenshot names for Data() iterations with uniqueScreenshotNames: true failed as expected before the fix.

  • Fix timestamp precision from seconds to milliseconds in testToFileName
  • Move unique suffix application after data part removal to preserve uniqueness
  • Add comprehensive unit tests for Data() scenario collision prevention
  • Ensure each Data() iteration gets unique screenshot filename instead of overwriting

Resolves issue where Data() test iterations were overwriting screenshots with identical filenames when uniqueScreenshotNames: true was enabled.

Applicable helpers:

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

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)

…hotNames

- Fix timestamp precision from seconds to milliseconds in testToFileName
- Move unique suffix application after data part removal to preserve uniqueness
- Add comprehensive unit tests for Data() scenario collision prevention
- Ensure each Data() iteration gets unique screenshot filename instead of overwriting

Resolves issue where Data() test iterations were overwriting screenshots with
identical filenames when uniqueScreenshotNames: true was enabled.

Fixes codeceptjs#5298
Copy link
Contributor

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.

Pull Request Overview

This PR fixes a bug where Data() test iterations were overwriting screenshots with identical filenames when uniqueScreenshotNames: true was enabled. The fix corrects the order of operations in the testToFileName function and improves timestamp precision.

  • Moves unique suffix application to after data part removal in filename generation
  • Changes timestamp precision from seconds (10 digits) to milliseconds (13 digits) for better uniqueness
  • Adds comprehensive unit tests to verify the fix prevents filename collisions in Data() scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/mocha/test.js Reorders operations to apply unique suffix after removing data part from test title, ensuring uniqueness is preserved; changes timestamp from seconds to milliseconds
test/unit/plugin/screenshotOnFail_test.js Updates existing tests to expect 13-digit millisecond timestamps; adds new test suite for Data() scenarios to verify unique filename generation
Comments suppressed due to low confidence (1)

test/unit/plugin/screenshotOnFail_test.js:150

  • Unused variable originalSaveScreenshot.
      const originalSaveScreenshot = screenshotSaved

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Apply Copilot review suggestion to remove the unused originalSaveScreenshot variable that was assigned but never used.
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.

Plugin: screenshotOnFail: Data driven scenarios ignore the setting "uniqueScreenshotNames: true"

1 participant