On a fresh install of the extension, it didn't work properly for me right out of the box either. Running npm run test
on the WSL2 terminal worked, but the extension didn't.
My folder structure was
root
__tests__
__testThis__
featureA.js <-- jest tests
__andThis__
feature1.js <--
feature2.js <--
testThis.js
andThis.js
package.json
and my test script was initially "test": "jest --watchAll --maxWorkers=1",
on my package.json.
But it finally worked after doing the ff.:
(1) Jest icon not appearing in bottom status bar
- Specify jest.rootPath in .vscode/settings.json . Documentation elaborates more on this here.
- I set mine as "" (empty) since I used testMatch to find my tests.
"jest.rootPath": "",
(2) jest command not found
- make sure jest and jest-cli are installed in the shell used by the jest extension
- I had been running tests using WSL2 with no issues (without the extension), but encountered "jest command not found" with the extension.
- After installing jest and jest-cli on Git Bash, this was no longer a problem.
(3) Extension runs for a split second, then "watch-tests" ended unexpectedly
(4) Tests finally run, but they run repeatedly until CPU usage goes --> ~90%
- turn jest autoRun off in .vscode/settings.json
"jest.autoRun": "off",
- click thru the jest extension's side bar icon (the Erlenmeyer flask) to run tests only as needed
Even then, not everything in the extension works perfectly (e.g. the debugger still doesn't work for me), but am able to run single tests (or all tests at once) using the extension.
Hope this helps somehow!