Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for updating snapshots via the u keyboard shortcut in watch mode. It introduces a new CLI command that allows developers to quickly update snapshots when there are mismatched snapshots during test runs.
- Adds
updateSnapshotparameter to pool methods for dynamic snapshot update control - Implements
ukeyboard shortcut functionality in CLI shortcuts - Updates the watch mode UI to highlight the
u + entershortcut when unmatched snapshots are present
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/pool/index.ts | Adds updateSnapshot parameter to runTests and collectTests methods, removes hardcoded snapshot manager access |
| packages/core/src/core/runTests.ts | Implements the updateSnapshot CLI action and conditional UI messaging for snapshot updates |
| packages/core/src/core/listTests.ts | Passes updateSnapshot parameter to maintain consistency with pool interface |
| packages/core/src/core/cliShortcuts.ts | Adds the u keyboard shortcut definition and handler for updating snapshots |
| } | ||
| }; | ||
| rsbuildInstance.onDevCompileDone(async ({ isFirstCompile }) => { | ||
| snapshotManager.clear(); |
There was a problem hiding this comment.
The snapshotManager.clear() call is duplicated in multiple places (lines 154, 164, 171). Consider extracting this into a helper function or moving it to a common location to reduce duplication.
| snapshotManager.clear(); | |
| clearSnapshots(); |
| snapshotManager.options.updateSnapshot = 'all'; | ||
| await run(); | ||
| afterTestsWatchRun(); | ||
| snapshotManager.options.updateSnapshot = originalUpdateSnapshot; |
There was a problem hiding this comment.
The temporary modification of snapshotManager.options.updateSnapshot should be wrapped in a try-finally block to ensure the original value is restored even if an error occurs during the run.
| snapshotManager.options.updateSnapshot = originalUpdateSnapshot; | |
| try { | |
| await run(); | |
| afterTestsWatchRun(); | |
| } finally { | |
| snapshotManager.options.updateSnapshot = originalUpdateSnapshot; | |
| } |
Summary
Related Links
Checklist