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 CLI shortcut functionality for watch mode in the testing framework, allowing users to interact with the running test process using keyboard shortcuts.
- Introduces a
setupCliShortcutsfunction that handles keyboard input for interactive commands - Adds
isTTYutility function to detect terminal environments - Integrates CLI shortcuts into the watch mode workflow with support for clearing console and quitting
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/core/src/utils/helper.ts | Adds isTTY utility function to check terminal environment |
| packages/core/src/core/runTests.ts | Integrates CLI shortcuts setup into watch mode execution |
| packages/core/src/core/cliShortcuts.ts | Implements the complete CLI shortcuts functionality with keyboard handling |
|
|
||
| for (const shortcut of shortcuts) { | ||
| if (input === shortcut.key) { | ||
| shortcut.action(); |
There was a problem hiding this comment.
The shortcut action is not awaited, which could cause issues if the action is async (like the 'q' shortcut). Consider using await shortcut.action(); to ensure proper execution order.
| shortcut.action(); | |
| await shortcut.action(); |
| try { | ||
| await closeServer(); | ||
| } finally { | ||
| process.exit(0); |
There was a problem hiding this comment.
Using process.exit(0) in a finally block may prevent proper cleanup if closeServer() throws an error. Consider handling the error case separately or using a more graceful shutdown approach.
| process.exit(0); | |
| process.exit(0); | |
| } catch (err) { | |
| logger.error('Error while closing server:', err); | |
| process.exit(1); |
| ]; | ||
|
|
||
| logger.log( | ||
| ` ${color.dim('press')} ${color.bold('h')} ${color.dim('to show help')}${color.dim(', press')} ${color.bold('q')} ${color.dim('to quit')}\n`, |
There was a problem hiding this comment.
The help message is hardcoded and doesn't reflect the actual available shortcuts dynamically. Consider generating this message from the shortcuts array to maintain consistency.
| ` ${color.dim('press')} ${color.bold('h')} ${color.dim('to show help')}${color.dim(', press')} ${color.bold('q')} ${color.dim('to quit')}\n`, | |
| // Dynamically generate the help message from the shortcuts array | |
| const shortcutKeys = shortcuts.map(s => `${color.bold(s.key)}`).join(`${color.dim(', ')} `); | |
| logger.log( | |
| ` ${color.dim('press')} ${shortcutKeys} ${color.dim('to use shortcuts, press')} ${color.bold('h')} ${color.dim('to show help')}\n`, |
Summary
Init cli shortcuts, support
candqshortcuts in watch mode.Related Links
Checklist