-
Notifications
You must be signed in to change notification settings - Fork 152
Change test script to interactive mode #328
Description
At the moment, tests inside Guppy are running once and the user need to re-run manually. As @joshwcomeau mentioned in a comment that's a temporary hack.
It was a good idea from Josh to do this later as this is a pretty large task. But maybe two people could work on this.
One for implementing the UI with jest-stare and the other for parsing/handling the interactive commands. But it's also possible to tackle this with-out splitting - just do it like this: First UI then command handling or start with a minimal temporary UI and work on the business logic first then improve UI.
Is your feature request related to a problem? Please describe.
UX could be better if it would be possible to use interactive mode.
Describe the solution you'd like
By removing line 188 to 190 in task.saga. We're running in interactive mode and the output in a terminal will look like in the following screenshot (ran in a real terminal as the Guppy output seems to be filtered):

Todos
UI
- Remove terminal from test preview as we're rendering everything to the UI
- The status should change if the interactive test is passing to green & on fail to red.
- Extract every info from the terminal output from top down to string
Watch usage. Maybe we could also change to a json reporter so it's easier to get the output - not sure if this is working with interactive mode. - Render the test result - I think we could use jest-stare to render it.
- Show progress bar & expected test time (optional, less important)
- Create a UI element for each command:
- Run all tests
akey - Run only failed tests
fkey - Filtering
p&tkey with a input field - Stop tests
qkey - Re-run test
enterkey
- Run all tests
- Use the same keys as keyboard shortcuts so it's possible to trigger them with keyboard.
Command handling
- Create a
runTestgenerator intask.sagathat's listening for a Redux action that will pass the command to the test child process. So you have to usetake(stdioChannel)andtakeEvery(TRIGGER_TEST_COMMAND, handleTestCommand)inside awhile(true)loop. -
handleTestCommandwill usesendCommandToProcessto send the command passed with the actionTRIGGER_TEST_COMMANDto the test child process.
Edge cases
- What happens if a snapshot needs to be updated? Parse the info from the output and display a button & also show a list of snapshot files that are not matching so they can be opened in editor. Jest-stare is already doing a nice diff display - maybe we could display this if we're detecting that a snapshot failed.