vscode-mocha-test-adapter
vscode-mocha-test-adapter copied to clipboard
Couldn't load options using mocha - w/ reproduction
Attached is a minimum reproduction.
I can't get a simple test to show up in the test explorer.
The error gives "Couldn't load options using mocha"
My structure is relatively simple, and I have a "backend" folder which I inform the test explorer of using
"mochaExplorer.configFile": "backend/.mocharc.json",
"mochaExplorer.cwd": "${workspaceFolder}/backend",
In my own project, I can run the tests manually. In the reproduction above, I cant even do that (complains about ts extension), however that's another issue. I would be happy to just see the test in the explorer, the rest works in my project.
I have tried using @swc/register (I use swc), and ts-node/register -- Same problem, can't load options
Error: Couldn't load options using mocha: error from child process Error: spawn /Users/admin/.nvm/versions/node/v20.11.0/bin/node ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:286:19) at onErrorNT (node:internal/child_process:484:16) at processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /Users/admin/.nvm/versions/node/v20.11.0/bin/node', path: '/Users/admin/.nvm/versions/node/v20.11.0/bin/node', spawnargs: [ '/Users/admin/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/out/worker/loadConfig.js', '--config', '/Users/admin/code/my-project/backend/.mocharc.json' ] } at ChildProcess.
(/Users/admin/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/out/optsReader.js:97:32) at Object.onceWrapper (node:events:634:26) at ChildProcess.emit (node:events:519:28) at ChildProcess.emit (node:domain:488:12) at Process.ChildProcess._handle.onexit (node:internal/child_process:292:12) at onErrorNT (node:internal/child_process:484:16) at processTicksAndRejections (node:internal/process/task_queues:82:21)
This is such a simple setup, what is wrong here.
@parliament718 I saw this in the bounty you raised in the replit. I have fixed it. Do have a look at the replit submission.
Same issue, I have my tests in a tests folder. They work with mocha using CLI. But I cannot make them run in the test explorer, I got a "Test discovery failed":
[Error: Couldn't load options using mocha: error from child process [Error: spawn /home/laurent/.local/share/pnpm/node ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:286:19)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)] {
errno: -2,
code: 'ENOENT',
syscall: 'spawn /home/laurent/.local/share/pnpm/node',
path: '/home/laurent/.local/share/pnpm/node',
spawnargs: [
'/home/laurent/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/out/worker/loadConfig.js',
'--config',
'/home/laurent/projects/futuroscore/${workspaceFolder}/tests/.mocharc.jsonc'
]
}
at ChildProcess.<anonymous> (/home/laurent/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/out/optsReader.js:97:32)
at Object.onceWrapper (node:events:634:26)
at ChildProcess.emit (node:events:519:28)
at ChildProcess.emit (node:domain:488:12)
at ChildProcess._handle.onexit (node:internal/child_process:292:12)
at onErrorNT (node:internal/child_process:484:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)]
Stacktrace:
at x.syncTopLevel (/home/laurent/.vscode/extensions/ms-vscode.test-adapter-converter-0.2.0/out/extension.js:5:3)
at gh.value (/home/laurent/.vscode/extensions/ms-vscode.test-adapter-converter-0.2.0/out/extension.js:2:4519)
at T.B (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:732)
at T.fire (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:950)
at gh.value (/home/laurent/.vscode/extensions/hbenl.vscode-test-explorer-2.22.1/out/hub/testHub.js:53:43)
at T.B (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:732)
at T.fire (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:29:950)
at MochaAdapter.<anonymous> (/home/laurent/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/out/core.js:144:35)
at Generator.throw (<anonymous>)
at rejected (/home/laurent/.vscode/extensions/hbenl.vscode-mocha-test-adapter-2.14.1/node_modules/tslib/tslib.js:116:69)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)