lundi 28 mars 2016

Karma+jspm+phantomjs "Could not load PhantomJS"

I'm running an Aurelia project on Windows and want to run Karma with PhantomJs. I also have JSPM and Babel similarly in the skeleton project here.

[karma]: No captured browser, open http://localhost:9876/
[karma]: Karma v0.13.22 server started at http://localhost:9876/
[launcher]: Can not load "PhantomJS"!
  RangeError: Maximum call stack size exceeded
    at XXX\node_modules\di\lib\injector.js:119:19
    at Array.forEach (native)
    at XXX\node_modules\di\lib\injector.js:115:27
    at Array.forEach (native)
    at new Injector (XXX\node_modules\di\lib\injector.js:104:11)
    at createChild (XXX\node_modules\di\lib\injector.js:93:12)
    at module.(anonymous function) (XXX\node_modules\karma\lib\config.js:198:31)

Here is my karma.conf.js:

module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: ['jspm', 'jasmine'],
    plugins: [
        'karma-babel-preprocessor',
        'karma-jspm',
        'karma-jasmine',
        'karma-phantomjs-launcher'
    ],
    jspm: {
      loadFiles: ['src/**/*.js', 'test/**/*.js'],
      serveFiles: ['src/**/*.js'],
      paths: {
        '*': '*',
        'github:*': 'jspm_packages/github/*',
        'npm:*': 'jspm_packages/npm/*'
      }
    },
    preprocessors: {
     'test/**/*.js': ['babel'],
     'src/**/*.js': ['babel']
    },
    'babelPreprocessor': {
      options: {
        sourceMap: 'inline',
        moduleIds: false,
        optional: [
          'es7.decorators',
          'es7.classProperties'
        ]
      }
    },

    defaultJSExtensions: true,
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    proxies : {
        '/src/': '/base/src/',
        '/jspm/': '/base/jspm/'
    },
    browsers: ['PhantomJS'],
    customLaunchers: {
        'PhantomJS': {
            base: 'PhantomJS',
            options: {
              settings: {
                webSecurityEnabled: false
              },
            },
            flags: ['--load-images=true'],
            // debug: true
        }
     },
     phantomjsLauncher: {
        exitOnResourceError: true
     },
    singleRun: false
  });
};

Here is my Gulp file:

var gulp = require('gulp');
var Karma = require('karma').Server;
/**
 * Run test once and exit
 */

var karmaConf = __dirname + '/../../karma.conf.js';
gulp.task('test', function(done) {
  new Karma({
    configFile: karmaConf,
    singleRun: false
  }, done).start();
});
/**
 * Watch for file changes and re-run tests on each change
 */
gulp.task('tdd', function(done) {
  new Karma({
    configFile: karmaConf
  }, done).start();
});

/**
 * Run test once with code coverage and exit
 */
gulp.task('cover', function(done) {
  new Karma({
    configFile: karmaConf,
    singleRun: true,
    reporters: ['coverage'],
    preprocessors: {
      'test/**/*.js': ['babel'],
      'src/**/*.js': ['babel', 'coverage']
    },
    coverageReporter: {
      includeAllSources: true,
      instrumenters: {
        isparta: require('isparta')
      },
      instrumenter: {
        'src/**/*.js': 'isparta'
      },
      reporters: [
        { type: 'html', dir: 'coverage' },
        { type: 'text' }
      ]
    }
  }, done).start();
});

Also, my versions:

  • JSPM: 0.16.15
  • NPM: 3.8.3
  • Gulp: 3.9.1
  • Karma: 0.13.22

I do have my PhantomJS path set (running >phanthomjs works).

Thank you in advance

Aucun commentaire:

Enregistrer un commentaire