Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't load options using mocha - w/ reproduction #255

Open
parliament718 opened this issue Sep 7, 2024 · 2 comments
Open

Couldn't load options using mocha - w/ reproduction #255

parliament718 opened this issue Sep 7, 2024 · 2 comments

Comments

@parliament718
Copy link

parliament718 commented Sep 7, 2024

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"

mocha-test.zip

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 parliament718 changed the title Couldn't load options using mocha Couldn't load options using mocha - w/ reproduction Sep 7, 2024
@vkolgi
Copy link

vkolgi commented Oct 4, 2024

@parliament718 I saw this in the bounty you raised in the replit. I have fixed it. Do have a look at the replit submission.

@laurentpayot
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants