Checklist
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
server folder
- A multi-root workspace containing both
server and 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
Further details
No response
Checklist
Actual behavior
Hi! I’ve run into a test discovery problem with a multi-root VS Code workspace.
My repository has a
serverpackage with its own.mocharc.cjs. Everything works when I open only theserverfolder: 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
serverfolder.For now, my workaround is to use a separate workspace containing only the
serverfolder.Thanks for taking a look!
Expected behavior
I’d expect
server/.mocharc.cjsto be registered once, preferably using the nestedserverworkspace folder as its context.Ideally, the same setup would work whether I open:
serverfolderserverand its parent repositoryMinimal, 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:
What happens
Both workspace folders seem to find the same Mocha config:
The second registration then fails:
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.cjswhile the multi-root workspace is open.Output
The second registration then fails:
Plugin Version Details
Environment
1.4.0v1.4.0+bd847bf1.137.024.18.011.8.0VS Code Version Details
1.137.0Further details
No response