fix: restore screenshot counters correctly on test retry - #415
Merged
Merged
Conversation
The retry handling in generateScreenshotPath only remembered the last screenshot path handed out during the previous attempt, so a retried test that took screenshots under several titles (or several of the same title) got different `_#n` names than the attempt that failed. It also could not tell a retry apart from the next test starting at retry 0, and rewound counters that belonged to earlier tests. Track the counters as they were before the current attempt for every path the attempt touched, keyed by a stable test id passed from the command, and restore all of them when the same test retries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
The retry handling in
generateScreenshotPathonly remembered the last screenshot path handed out during the previous attempt. So a retried test that took screenshots under a couple of titles (or several under the same title) ended up with different_#nnames than the attempt that failed, which then produced fresh baselines instead of comparing against the right ones.It also had no way to tell "retry of this test" apart from "next test that happens to start at retry 0", and could rewind counters that belonged to earlier tests.
This tracks the counters as they were before the current attempt for every path the attempt touched, keyed by a stable test id (
cy.state('test').id, with a spec + title fallback), and restores all of them when the same test retries. Added a test file for the path generator covering the cases above.馃 Generated with Claude Code