Describe the bug
jest.virtualFolders is ignored when placed in a workspace folder's .vscode/settings.json in a multi-root workspace. The extension falls back to auto-detection and fails with "Not able to auto detect a valid jest command: multiple candidates found". Other jest settings like jest.rootPath and jest.jestCommandLine work correctly from the same file.
The root cause is that jest.virtualFolders in the extension's package.json does not have a "scope" property, which defaults to "window" in VS Code. This restricts it to user-level or workspace-level settings only. Every other jest setting has "scope": "resource", which allows reading from folder-level .vscode/settings.json.
The fix is a one-liner — add "scope": "resource" to the jest.virtualFolders definition in package.json:
"jest.virtualFolders": {
"markdownDescription": "...",
"type": ["array", "null"],
"default": null,
- "items": { "type": "object" }
+ "items": { "type": "object" },
+ "scope": "resource"
}
To Reproduce
- Open a multi-root workspace (
.code-workspace) containing a folder with two sub-packages that each have their own jest.config.ts and node_modules
- Add
jest.virtualFolders to that folder's .vscode/settings.json:
"jest.virtualFolders": [
{ "name": "pkg-a", "rootPath": "pkg-a", "jestCommandLine": "node_modules/.bin/jest" },
{ "name": "pkg-b", "rootPath": "pkg-b", "jestCommandLine": "node_modules/.bin/jest" }
]
- Reload the window
- The extension ignores the setting, runs auto-detection, and fails with:
[error] Not able to auto detect a valid jest command: multiple candidates found
[error] Jest process exited unexpectedly: Process failed to start: Error: [<folder>] missing jestCommandLine
- Move the same
jest.virtualFolders setting to user-level settings.json — it works correctly
Expected behavior
jest.virtualFolders should be read from the workspace folder's .vscode/settings.json, just like jest.rootPath, jest.jestCommandLine, and all other jest settings with "scope": "resource".
Screenshots
N/A — the error is in the Jest output channel.
Environment (please complete the following information):
- vscode-jest version: v6.4.4
node -v: 22.17.0
yarn --version: 4.9.4
- jest version: 30.0.0
- your vscode-jest settings:
- jest.jestCommandLine:
node_modules/.bin/jest (inside virtualFolders)
- jest.runMode: default (watch)
- jest.outputConfig: default
jest.virtualFolders configured with two sub-packages, each with their own rootPath and jestCommandLine
- Operating system: macOS
Prerequisite
- are you able to run jest from the command line? Yes
- where do you run jest CLI from? From each sub-package directory
- how do you run your tests from the command line?
node_modules/.bin/jest
Additional context
The issue is in package.json of the extension. The jest.virtualFolders setting definition is missing "scope": "resource". Without it, VS Code defaults the scope to "window", which means it's only read from user or workspace-level settings — never from folder-level .vscode/settings.json. All other jest settings (jest.rootPath, jest.jestCommandLine, jest.enable, jest.runMode, etc.) already have "scope": "resource" and work correctly from folder settings.
Describe the bug
jest.virtualFoldersis ignored when placed in a workspace folder's.vscode/settings.jsonin a multi-root workspace. The extension falls back to auto-detection and fails with "Not able to auto detect a valid jest command: multiple candidates found". Other jest settings likejest.rootPathandjest.jestCommandLinework correctly from the same file.The root cause is that
jest.virtualFoldersin the extension'spackage.jsondoes not have a"scope"property, which defaults to"window"in VS Code. This restricts it to user-level or workspace-level settings only. Every other jest setting has"scope": "resource", which allows reading from folder-level.vscode/settings.json.The fix is a one-liner — add
"scope": "resource"to thejest.virtualFoldersdefinition inpackage.json:"jest.virtualFolders": { "markdownDescription": "...", "type": ["array", "null"], "default": null, - "items": { "type": "object" } + "items": { "type": "object" }, + "scope": "resource" }To Reproduce
.code-workspace) containing a folder with two sub-packages that each have their ownjest.config.tsandnode_modulesjest.virtualFoldersto that folder's.vscode/settings.json:jest.virtualFolderssetting to user-levelsettings.json— it works correctlyExpected behavior
jest.virtualFoldersshould be read from the workspace folder's.vscode/settings.json, just likejest.rootPath,jest.jestCommandLine, and all other jest settings with"scope": "resource".Screenshots
N/A — the error is in the Jest output channel.
Environment (please complete the following information):
node -v: 22.17.0yarn --version: 4.9.4node_modules/.bin/jest(inside virtualFolders)jest.virtualFoldersconfigured with two sub-packages, each with their ownrootPathandjestCommandLinePrerequisite
node_modules/.bin/jestAdditional context
The issue is in
package.jsonof the extension. Thejest.virtualFolderssetting definition is missing"scope": "resource". Without it, VS Code defaults the scope to"window", which means it's only read from user or workspace-level settings — never from folder-level.vscode/settings.json. All other jest settings (jest.rootPath,jest.jestCommandLine,jest.enable,jest.runMode, etc.) already have"scope": "resource"and work correctly from folder settings.