I can't find any information on debugging my unit tests written with Jest.
How do you debug Jest Tests ?
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.
Debug the Rewired Create React App Unit Test Cases json : Line 18 is a must to use Chrome DevTools for debugging unit test cases. Here the executable is react-app-rewired . It can be invoked by typing npm run test:debug .
You do not need Chrome
for Jest tests.
The simplest solution I found is to use VS Code JavaScript Debug Terminal
.
And it works with Typescript and Nrvl.Nx work-spaces out of the box.
Debug: JavaScript Debug Terminal
:npm test --watch
.watch
will run Jest tests against modified files.When you want to narrow down the number of files run by the --watch, press p
in the terminal and enter a pattern, which is just a part of the file name you want to test and hit [Enter]
To limit it to a single test in a file - focus it with f, so change it(...) to fit(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With