Karma: error loading plugin "karma-phantoms-launcher"

I am trying to run tests on Centos 7 in a Node.js environment (6.1.0). After launch

./node_modules/karma/bin/karma --log-level debug start 

I get an error message:

 Error during loading "karma-phantomjs-launcher" plugin: Path must be a string. Received null 

In karma.conf.js, I mentioned plugins and a browser:

 'plugins': ['karma-mocha', 'karma-chai', 'karma-sinon', 'karma-chai-sinon', 'karma-coverage', 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-chrome-launcher', 'karma-babel-preprocessor'], browsers: ['PhantomJS'], 

I also installed all the plugins locally for the project. All other plugins load without problems.

I also have the same project that runs on Windows 7 without any problems.

+8
phantomjs karma-runner
source share
3 answers

Removing the node_modules directory and reinstalling npm packages again helped me:

 rm -r node_modules/ 

or using rimraf :

 rimraf node_modules/ 

and re-adding all the dependencies:

 npm i 
+10
source share

I think this is due to the fact that I was trying to use phantomjs-prebuilt . Here is what I did, installed phantomjs and added to karma.conf.js

following:
 process.env.PHANTOMJS_BIN = './node_modules/.bin/phantomjs' 

Because he complained about the absence of PhantomJs otherwise:

 [launcher]: No binary for PhantomJS browser on your platform. Please, set "PHANTOMJS_BIN" env variable. 
0
source share

Since we did not use phantomjs for testing, I was able to solve the problem by removing "karma-phantomjs-launcher" from karma.conf.js

0
source share

All Articles