hbenl / vscode-mocha-test-adapter

Mocha Test Adapter for the VS Code Test Explorer
MIT License
90 stars 31 forks source link

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

Open parliament718 opened 1 month ago

parliament718 commented 1 month ago

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.

vkolgi commented 1 week ago

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