Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different jest.jestCommandLine settings for run vs debug #1081

Open
nbolton opened this issue Oct 17, 2023 · 1 comment
Open

Different jest.jestCommandLine settings for run vs debug #1081

nbolton opened this issue Oct 17, 2023 · 1 comment

Comments

@nbolton
Copy link

nbolton commented Oct 17, 2023

Feature request

I'm using fnm on Linux to select my node version, and I've managed to set jest.jestCommandLine in settings.json to use the correct Node version according to the .nvmrc in my project:

  "jest.jestCommandLine": "fnm use --version-file-strategy recursive && npm test --",

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:

/run/user/1000/fnm_multishells/1082892_1697542670710/bin/node ./fnm use --version-file-strategy recursive \&\& npm test --

This of course gives me a Cannot find module error, since fnm 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:

if (this.extContext.settings.jestCommandLine) {

Workaround

For now, I'll just use fnm default x to set the Node version globally.

@nbolton nbolton changed the title Possible to use different jest.jestCommandLine for run vs debug? Different jest.jestCommandLine settings for run vs debug Oct 17, 2023
@connectdotz
Copy link
Collaborator

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 on jest.jestCommandLine)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants