karma-runner / karma-phantomjs-launcher

A Karma plugin. Launcher for PhantomJS.
MIT License
281 stars 131 forks source link

PhantomJS cannot run tests #129

Open XiaonuoGantan opened 8 years ago

XiaonuoGantan commented 8 years ago

When karma runs the tests using Chrome, then the tests run successfully. When karma runs them using PhantomJS, however, the following error will be triggered:

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: JSON Parse error: Unexpected identifier "undefined"
  at undefined:16

My package.json file:

...
    "phantomjs": "^2.1.1",
    "karma": "^1.1.1",
    "karma-chai-plugins": "^0.7.0",
    "karma-coverage": "^1.1.0",
    "karma-jasmine": "^1.0.2",
    "karma-mocha": "^1.1.1",
    "karma-mocha-reporter": "^1.1.1",
    "karma-phantomjs-launcher": "^1.0.1",
    "karma-phantomjs-shim": "^1.4.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "^1.7.0",
...

My karma.conf.js file:

...
    browsers: ['PhantomJS'],
    files: [
      'test/loadtests.js'
    ],
    port: 9090,
    captureTimeout: 60000,
    frameworks: ['phantomjs-shim', 'mocha', 'chai', 'chai-as-promised'],
...
tmcgann commented 7 years ago

Wherever you are parsing JSON, seems you have a value that is specified as undefined which is not a valid JSON value. PhantomJS may be handling this differently than Chrome?

This SO Q/A discusses JSON and undefined: http://stackoverflow.com/questions/13796751/json-undefined-value-type

molayaias commented 6 years ago

There is a solution for this problem?

I have the same issue, when I run using PhantomJS browser i get error, but when I run using ChromeHeadless tests run ok.

Help!

Regards,