It seems that #191 is back.
node -v: 8.16.0npm -v: 6.4.1yarn -v: 1.16.0npm ls jest or npm ls react-scripts (if you haven鈥檛 ejected): 24.8.0your vscode-jest settings if customized:
./node_modules/jest/bin/jest.js --onlyChanged --coverage./dev/tools/jest-runner/jest.config.jsOperating system: macOS 10.14.4
yarn test which calls jest --config dev/tools/jest-runner/jest.config.jsthis issue has come up a few times, let's take this opportunity to discuss
pathToConfigActually codelens not only does not incorporate pathToConfig it also doesn't use pathToJest. Because like most IDEs, vscode has its own debug architecture. It spawned its own node process following its debug configuration in launch.json.
The debug codelens will always look for the debug config named vscode-jest-tests in users "launch.json". If no such config found, it then falls back to a simple default debug config, which works for simple/basic projects but most likely not adequate for more sophisticated projects.
_"ok, I can't use jest.pathToJest but can't you add jest.pathToConfig to the default debug config?"_, you might ask...
Indeed we could, but you can also imagine that some projects might need different jest config for debugging vs. regular test run, so maybe we should add a separate jest.pathToDebugConfig? You can see in order to keep up with various development environments and frameworks, we can either keep expanding our configurations and risking overlapping/reinventing-the-wheel with vscode's, or we can help users to adopt vscode's native debug config, which is a useful skill beyond jest debug anyway... thus we choose the latter approach.
knowing why we choose this approach, now let's try to resolve your issue. This extension provides a few debug config baseline you can use:
first, go to your debug view and open the launch.json so you can add the debug config, see vscode instruction.
when asking selecting debug environment or when clicking on the "add configuration..." button, choose one of the jest debug config mentioned above. In your case, you would probably choose "Jest: Default jest configuration" and add a config argument like below:
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand",
"--config",
"./dev/tools/jest-runner/jest.config.js"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
},
vscode is gaining popularity, there is a large community to discuss and share information about how to configure vscode debugger, such as this. And we always welcome PRs to add more debug config snippets for other popular use cases.
@connectdotz thank you for that detailed response. This is incredibly helpful. I'm closing this out.
This should be documented in a Wiki page or something like that I think
Also requesting that this gets documented - it was not easy for me to find this relatively simple answer. Even a tiny note somewhere more obvious would be appreciated 馃憤
Most helpful comment
this issue has come up a few times, let's take this opportunity to discuss
why debug codelens doesn't use
pathToConfigActually codelens not only does not incorporate
pathToConfigit also doesn't usepathToJest. Because like most IDEs, vscode has its own debug architecture. It spawned its own node process following its debug configuration in launch.json.The debug codelens will always look for the debug config named
vscode-jest-testsin users "launch.json". If no such config found, it then falls back to a simple default debug config, which works for simple/basic projects but most likely not adequate for more sophisticated projects._"ok, I can't use
jest.pathToJestbut can't you addjest.pathToConfigto the default debug config?"_, you might ask...Indeed we could, but you can also imagine that some projects might need different jest config for debugging vs. regular test run, so maybe we should add a separate
jest.pathToDebugConfig? You can see in order to keep up with various development environments and frameworks, we can either keep expanding our configurations and risking overlapping/reinventing-the-wheel with vscode's, or we can help users to adopt vscode's native debug config, which is a useful skill beyond jest debug anyway... thus we choose the latter approach.how do you add the custom jest config for debugging?
knowing why we choose this approach, now let's try to resolve your issue. This extension provides a few debug config baseline you can use:
first, go to your debug view and open the
launch.jsonso you can add the debug config, see vscode instruction.when asking selecting debug environment or when clicking on the "add configuration..." button, choose one of the jest debug config mentioned above. In your case, you would probably choose "Jest: Default jest configuration" and add a config argument like below:
more...
vscode is gaining popularity, there is a large community to discuss and share information about how to configure vscode debugger, such as this. And we always welcome PRs to add more debug config snippets for other popular use cases.