feat: support filter test name regex pattern via t shortcut#462
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 filtering tests by name using a regex pattern through a new t keyboard shortcut in the CLI. This enhancement allows developers to interactively filter tests during watch mode without restarting the test runner.
Key changes:
- Adds
tshortcut to prompt for test name pattern input - Updates pool methods to accept context parameter for runtime configuration
- Implements interactive pattern input with real-time feedback
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
website/docs/zh/guide/basic/cli.mdx |
Updates Chinese documentation to include the new t shortcut |
website/docs/en/guide/basic/cli.mdx |
Updates English documentation to include the new t shortcut |
packages/core/src/pool/index.ts |
Modifies pool methods to accept context parameter and moves runtime config generation |
packages/core/src/core/runTests.ts |
Adds runWithTestNamePattern function and passes context to pool methods |
packages/core/src/core/listTests.ts |
Passes context parameter to pool's collectTests method |
packages/core/src/core/cliShortcuts.ts |
Implements interactive test name pattern filtering with t shortcut |
| try { | ||
| process.stdin.setRawMode(false); | ||
| process.stdin.pause(); | ||
| } catch {} |
There was a problem hiding this comment.
The empty catch block silently ignores all errors when setting raw mode to false. Consider logging the error or handling specific expected exceptions to avoid masking unexpected issues.
| } catch {} | |
| } catch (err) { | |
| logger.error('Error disabling raw mode or pausing stdin:', err); | |
| } |
| for (const shortcut of shortcuts) { | ||
| if (str === shortcut.key) { | ||
| shortcut.action(); | ||
| void shortcut.action(); |
There was a problem hiding this comment.
Using void to ignore the promise returned by shortcut.action() could mask errors. Consider adding error handling for async shortcut actions to ensure failures are properly logged or handled.
| void shortcut.action(); | |
| const result = shortcut.action(); | |
| if (result instanceof Promise) { | |
| result.catch((err) => { | |
| logger.error('Error executing shortcut action:', err); | |
| }); | |
| } |
Summary
support filter test name regex pattern via
tshortcut.Related Links
Checklist