enhance: only rerun failed snapshot test files when update snapshots#473
enhance: only rerun failed snapshot test files when update snapshots#473
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 optimizes snapshot testing by only rerunning test files that have failed snapshots when updating snapshots, rather than rerunning all test files. This improves performance by reducing unnecessary test execution during snapshot updates.
- Filter failed snapshot tests and only rerun those files during snapshot updates
- Add snapshot files (
**/*.snap) to the watch ignored patterns to prevent unnecessary rebuilds
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/core/runTests.ts | Filter test results to identify files with unmatched snapshots and pass them to the run function |
| packages/core/src/core/plugins/entry.ts | Add snapshot files to the watch ignored patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| return; | ||
| } | ||
| const failedTests = testFileResult | ||
| .filter((result) => result.snapshotResult?.unmatched) |
There was a problem hiding this comment.
The filter condition result.snapshotResult?.unmatched may not correctly identify all failed snapshot tests. Consider checking if unmatched is greater than 0, as it likely represents a count: .filter((result) => result.snapshotResult?.unmatched > 0)
| .filter((result) => result.snapshotResult?.unmatched) | |
| .filter((result) => (result.snapshotResult?.unmatched ?? 0) > 0) |
Summary
only rerun failed snapshot test files when update snapshots.
Related Links
Checklist