Closed nbolton closed 6 months ago
In debug, vscode uses its own configuration in the launch.json
. We attempt to generate a debug config based on the jest.jestCommandLine
if none is provided by users. This is a best effort and most likely won't cover all use cases. If it doesn't work for your project, it is recommended to create an explicit debug config instead: see https://github.com/jest-community/vscode-jest#debug-config-v2 (note the debug config has no dependency onjest.jestCommandLine
)
same issue
For those who landed here, the solution is to create a custom debug configuration. See Debug Config for more details. You can start by copying one of the examples in the Debug Config v2 section and adjust it with your desired custom command line.
I will close this issue as this is the intended behavior. If you encounter any problems while setting up the custom debug configuration, please open a new issue with your specific use case so we can assist you further.
Feature request
I'm using
fnm
on Linux to select my node version, and I've managed to setjest.jestCommandLine
insettings.json
to use the correct Node version according to the.nvmrc
in my project:This works fine for running tests normally (in the Jest 'Testing' activity), and from using 'Run test'.
However, when I use the 'Debug test' shortcut, e.g. to debug a specific test, it uses
jest.jestCommandLine
in a weird way; it prepends the full path of my system default Node binary (which is not the binary used for my project; that's an older Node version), so I get something like this:This of course gives me a
Cannot find module
error, sincefnm
isn't something Node can run.In this case, it'd be useful if we could use a different
jest.jestCommandLine
value for run and debug, since the value is used differently in each context.The relevant line seems to be: https://github.com/jest-community/vscode-jest/blob/10414abf47d9829d67ef8932fdd12bb472154ed9/src/JestExt/core.ts#L636
Workaround
For now, I'll just use
fnm default x
to set the Node version globally.