Skip to content

feat: support update snapshot via u shortcut#455

Merged
9aoy merged 2 commits intomainfrom
update-snapshot
Aug 8, 2025
Merged

feat: support update snapshot via u shortcut#455
9aoy merged 2 commits intomainfrom
update-snapshot

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 8, 2025

Summary

image

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 8, 2025 04:03
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 8, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit fe66a3c
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/689577219400ed00083a3dc5
😎 Deploy Preview https://deploy-preview-455--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
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 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 updateSnapshot parameter to pool methods for dynamic snapshot update control
  • Implements u keyboard shortcut functionality in CLI shortcuts
  • Updates the watch mode UI to highlight the u + enter shortcut 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();
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
snapshotManager.clear();
clearSnapshots();

Copilot uses AI. Check for mistakes.
snapshotManager.options.updateSnapshot = 'all';
await run();
afterTestsWatchRun();
snapshotManager.options.updateSnapshot = originalUpdateSnapshot;
Copy link

Copilot AI Aug 8, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
snapshotManager.options.updateSnapshot = originalUpdateSnapshot;
try {
await run();
afterTestsWatchRun();
} finally {
snapshotManager.options.updateSnapshot = originalUpdateSnapshot;
}

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit 33f17c8 into main Aug 8, 2025
17 checks passed
@9aoy 9aoy deleted the update-snapshot branch August 8, 2025 06:07
@9aoy 9aoy mentioned this pull request Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants