Andrzej Sawoniewicz
Andrzej Sawoniewicz

Reputation: 1681

Karma: Error during loading "karma-phantomjs-launcher" plugin

I am trying to run tests on Centos 7 within the Node.js (6.1.0) environment. After I run

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

I get the error message:

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

In karma.conf.js I have mentioned plugins and the 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 have installed all plugins locally for the project. All other plugins are loaded without a problem.

I have also the same project running on Windows 7 environment without a problem.

Upvotes: 8

Views: 12389

Answers (3)

jmunsch
jmunsch

Reputation: 24089

Since we weren't using phantomjs for testing, I was able to resolve the issue by removing "karma-phantomjs-launcher" from the karma.conf.js

Upvotes: 1

Beat
Beat

Reputation: 4412

Removing the node_modules directory and re-installing npm packages again helped me:

rm -r node_modules/

or with rimraf:

rimraf node_modules/

and re-adding all dependencies:

npm i

Upvotes: 10

firedev
firedev

Reputation: 21088

I guess it is related to the fact that I tried to use phantomjs-prebuilt. Here is what I did, installed phantomjs and added the following to karma.conf.js

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

Because it was complaining about missing PhantomJs otherwise:

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

Upvotes: 0

Related Questions