-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Feature request
My issue is easily solved by workarounds (below), so I won't mind if this issue gets closed. While writing this issue, I actually discovered that the first workaround (Turn off 'Sync This Setting') works perfectly well, and considered not raising this issue at all, but decided to share for posterity/awareness.
Minor problem: For fnm
users, the jest.jestCommandLine
setting is useful only if you develop on one operating system. When trying to use fnm
with this to manage Node versions, it's tricky, since fnm
reqires you to eval the fnm eval
command (which is done differently on each OS*). To solve this, I had to write a script, fnm-use
(see end of issue) and call that before npm test --
:
macOS:
"jest.jestCommandLine": "source fnm-use && npm test --"
Windows:
"jest.jestCommandLine": "fnm-use && npm test --"
Alternatively, just use the npm
hard coded path instead of using fnm
, but this only works on Windows (not macOS)...
"jest.jestCommandLine": "C:\\Users\\[username]\\AppData\\Local\\fnm_multishells\\20784_1693483119158\\npm.cmd test --",
Workarounds:
- Turn off 'Sync This Setting' for the
jest.jestCommandLine
and use the hard-codednpm
path (as above). - Turn off 'Sync This Setting' for the
jest.jestCommandLine
setting (and use mynpm-use
script below). - I haven't tried this yet, but I imagine that the workaround is to just use
nvm
instead offnm
, as arguably this is a unique problem thatfnm
creates. - Use the installed Node directly on the OS (instead of
fnm
) and install the required version of Node for the whole system. This is tricky if you work on different projects with different Node versions. - Use the settings profiles feature on the VS Code Insider version.
Possible solution: Not sure if this is the best solution since Similar to how other Node-reliant extensions work (e.g. Sonarlint), have an extension setting for node
itself:
"sonarlint.pathToNodeExecutable": "C:\\Users\\[username]\\AppData\\Local\\fnm_multishells\\4224_1692713362372\\node.exe",
I also noticed that the sonarlint.pathToNodeExecutable
setting is not sync'd by default, so it's not neccesary to turn off sync for that setting. Perhaps jest.jestCommandLine
should not be sync'd by default so you don't need to add it to settingsSync.ignoredSettings
.
Script source code
Windows Command Prompt (what Jest extension seems to use):
fnm-use.cmd
FOR /f "tokens=*" %%i IN ('fnm env --use-on-cd') DO CALL %%i
fnm use --version-file-strategy recursive
macOS script:
fnm-use.sh
:
export PATH="/Users/[username]/Library/Application Support/fnm:$PATH"
eval "`fnm env`"
fnm use --version-file-strategy recursive