Repository navigation
Description
Checklist
- I have read and agree to the Code of Conduct
- I have searched for related issues and discussions but they did not match this problem.
- I want to contribute a bugfix myself.
Actual behavior
Hi! I’ve run into a test discovery problem with a multi-root VS Code workspace.
My repository has a server package with its own .mocharc.cjs. Everything works when I open only the server folder: mocha-vscode finds the correct Mocha installation and discovers the full test suite (around 3,200 tests).
The problem appears when I open a workspace containing both the repository root and the nested server folder.
For now, my workaround is to use a separate workspace containing only the server folder.
Thanks for taking a look!
Expected behavior
I’d expect server/.mocharc.cjs to be registered once, preferably using the nested server workspace folder as its context.
Ideally, the same setup would work whether I open:
- Only the
serverfolder - A multi-root workspace containing both
serverand its parent repository
Minimal, Reproducible Example
Workspace setup
This works:
{
"folders": [
{
"name": "Server",
"path": "server"
}
]
}This does not:
{
"folders": [
{
"name": "Server",
"path": "server"
},
{
"name": "Repository",
"path": "."
}
]
}The relevant layout is:
repo/
project.code-workspace
server/
.mocharc.cjs
package.json
What happens
Both workspace folders seem to find the same Mocha config:
New Test Controller for workspace folder and config /path/to/repo/server /path/to/repo/server/.mocharc.cjs
New Test Controller for workspace folder and config /path/to/repo /path/to/repo/server/.mocharc.cjs
The second registration then fails:
Error: Attempt to insert a duplicate controller with ID "file:///path/to/repo/server/.mocharc.cjs"
at ...createTestController...
at ...coderline.mocha-vscode-1.4.0/out/extension.js...
at ...addConfigFile...
After that, the Testing view either shows no tests or only part of the suite. It can also appear to resolve Mocha from the wrong workspace-folder context.
I can reproduce the duplicate-controller error especially reliably by creating, moving, or recreating server/.mocharc.cjs while the multi-root workspace is open.
Output
The second registration then fails:
Error: Attempt to insert a duplicate controller with ID "file:///path/to/repo/server/.mocharc.cjs"
at ...createTestController...
at ...coderline.mocha-vscode-1.4.0/out/extension.js...
at ...addConfigFile...
Plugin Version Details
Environment
- mocha-vscode:
1.4.0 - Extension build:
v1.4.0+bd847bf - VS Code:
1.137.0 - macOS, arm64
- Node.js:
24.18.0 - Mocha:
11.8.0
VS Code Version Details
- VS Code:
1.137.0
Further details
No response
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Area
Platform
Work State
Activity