This is how I dynamically run tests on a specific file without restarting the test.
My React project was created as create-react-app
.
So it watches test for changes, automatically running test when I make changes.
So this is what I see at the end of the test results in the terminal:
Test Suites: 16 passed, 16 total
Tests: 98 passed, 98 total
Snapshots: 0 total
Time: 5.048s
Ran all test suites.
Watch Usage: Press w to show more.
Press W
Watch Usage
› Press f to run only failed tests.
› Press o to only run tests related to changed files.
› Press q to quit watch mode.
› Press p to filter by a filename regex pattern.
› Press t to filter by a test name regex pattern.
› Press Enter to trigger a test run.
Then press P
Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to filter by a filenames regex pattern.
pattern ›
Start typing to filter by a filename regex pattern.
This is after I wanted to run the 'index.es6.js' file in the 'Login' folder:
Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to filter by a filenames regex pattern.
pattern › login/index
Pattern matches 1 file
› src/containers/Login/index.es6.test.js
That's how I run tests on a specific file.