feat: support rerun failed tests via f shortcut#456
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 implements a new CLI shortcut feature that allows users to rerun only failed tests by pressing f during watch mode. The feature provides a quick way to focus on fixing failing tests without re-running the entire test suite.
- Adds a new
fCLI shortcut for rerunning failed tests - Implements file filtering to only build and run tests that previously failed
- Adds build hash tracking to optimize rebuild performance for filtered test runs
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/core/src/core/runTests.ts | Adds failed test tracking, implements runFailedTests function, and integrates with CLI shortcuts |
| packages/core/src/core/rsbuild.ts | Extends getRsbuildStats to support file filtering and adds build hash tracking |
| packages/core/src/core/cliShortcuts.ts | Registers the new f shortcut for rerunning failed tests |
packages/core/src/core/runTests.ts
Outdated
| totalTime: testTime + buildTime, | ||
| buildTime, | ||
| totalTime: testTime + currentBuildTime, | ||
| buildTime: currentBuildTime, |
There was a problem hiding this comment.
[nitpick] The logic for determining currentBuildTime could be clearer. Consider renaming the variable to actualBuildTime or adding a comment explaining that build time is set to 0 when the hash hasn't changed (indicating no rebuild occurred).
| } else if (sourceEntries[entry]) { | ||
| if ( | ||
| fileFilters?.length && | ||
| !fileFilters.includes(sourceEntries[entry]) |
There was a problem hiding this comment.
The file filtering logic iterates through all entries and uses includes() which has O(n) complexity for each check. For better performance with large numbers of failed tests, consider converting fileFilters to a Set for O(1) lookup time.
| !fileFilters.includes(sourceEntries[entry]) | |
| fileFiltersSet && | |
| !fileFiltersSet.has(sourceEntries[entry]) |
Summary
support rerun only failed tests via
fshortcut.Related Links
Checklist