Skip to content

[BUG]jest.virtualFolders is missing "scope": "resource" — ignored from folder-level .vscode/settings.json #1281

Description

@alex-kov

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

  1. 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
  2. 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" }
]
  1. Reload the window
  2. 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
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions