Source: https://stackoverflow.com/a/63909711
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.
- Open the command palette and start
Debug: JavaScript Debug Terminal
:
- Run tests in that terminal in a Watch mode
npm test -- --watch
. (oryarn test --watch
if you are using yarn) - Set a break-point in your file.
- Make any change in a file you want to debug and save.
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(…)