Getting error Failed to load tests - Karma server failed to start: spawn npx karma ENOENT
ideeeyut opened this issue · 2 comments
Describe the Bug
- When loading the Test Runner I get the error
Failed to load tests - Karma server failed to start: spawn npx karma ENOENT
Steps to Reproduce the Behavior
This appears to be a machine config issue. Other developers working on the same project are using this extension correctly. We have a case where one machine is not displaying any tests in the Test Explorer. The following error is found in the Karma Test Explorer ({project name}) output.
[2023-01-26 18:34:28.015] [ERROR] [KarmaCommandLineTestServerExecutor::SimpleProcess]: Process gsmk4wyqh5 - Error from child process: 'Error: spawn npx karma ENOENT' - for command: npx karma start /home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf --no-single-run
Describe the Expected Behavior
- Test should be displayed in the Test Explorer
Provide Debug Logs
- With the
karmaTestExplorer.logLevel
set todebug
, please capture and attach the logs from all theKarma Test Explorer
Output channels when the issue occurs.
KarmaTestExplorer-singularity.txt
KarmaTestExplorer-workspace.txt
Please also capture and attach the logs from all the Karma Server
Output channels when the issue occurs.
It just has
------------------------------------
Karma Test Explorer: Launching Karma
------------------------------------
Provide a Minimal Reproduction Project
- In a public github repo, create a minimal project that reproduces the issue
- Provide a link to the project
Not available
Screenshots
- If applicable, add screenshots to help explain the issue you are having.
Please Provide the Following Information
- OS: Ubuntu 22.04
- Environment: n/a
- Node Version: 14.2.0
- VS Code Version: 1.74.3
- Karma Version: 6.4.1
- Frameworks: AngularJS/Angular Hybrid, Jasmine
Additional Context
Running the command that the log says errored
npx karma start /home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf --no-single-run
returns
26 01 2023 13:53:23.282:ERROR [config]: Error in config file!
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at new NodeError (internal/errors.js:322:7)
at validateString (internal/validators.js:124:11)
at Object.join (path.js:1148:7)
at Kt.default (/home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf.js:2:110773)
at gt.loadOriginalConfig (/home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf.js:2:111452)
at gt.loadConfig (/home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf.js:2:111309)
at module.exports (/home/dscott/.vscode/extensions/lucono.karma-test-explorer-0.8.0/dist/karma.conf.js:2:114463)
at Object.parseConfig (/home/dscott/src/singularity/node_modules/karma/lib/config.js:470:26)
at Object.exports.run (/home/dscott/src/singularity/node_modules/karma/lib/cli.js:288:26)
at Object.<anonymous> (/home/dscott/src/singularity/node_modules/karma/bin/karma:3:23)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at /home/dscott/.nvm/versions/node/v14.20.0/lib/node_modules/npm/node_modules/libnpx/index.js:268:14 {
code: 'ERR_INVALID_ARG_TYPE'
}
- Add any other context about the problem here.
It looks like your config includes the following setting:
"karmaTestExplorer.karmaProcessCommand": "npx karma"
The karmaProcessCommand
setting only accepts a single command or script, without arguments. If you remove that setting, the extension will by default use the node
executable from your PATH
and the karma
installation in your project.
If you'd instead like to use a global installation of karma
on the machine rather than one installed locally in the project, you can add the following config setting:
"karmaTestExplorer.allowGlobalPackageFallback": true
That got me through it and I'm seeing tests now. Thank you!!!