fix: prevent Data() screenshot filename collisions with uniqueScreenshotNames#5299
Merged
kobenguyent merged 2 commits intocodeceptjs:3.xfrom Nov 18, 2025
Merged
Conversation
…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
Contributor
There was a problem hiding this comment.
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: truefailed as expected before the fix.Resolves issue where Data() test iterations were overwriting screenshots with identical filenames when uniqueScreenshotNames: true was enabled.
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)