Karma does not work when using PhantomJS, but not in Chrome

I have a series of tests that pass when I use the Karma Chrome Launcher, but fail when I use the Karma PhantomJS launcher.

Here is my what's inside my karma.config.js file `` '' frames: ['browserify', 'mocha', 'chai', 'sinon'],

files: require('./include.conf.js').concat([
  'test/helper/*.js',
  'test/example/*.spec.js',
  'test/unit/*.spec.js',
  'test/integration/*.spec.js'
]),


// list of files to exclude
exclude: [
  'gulpfile.js',
  'index.js',
  'karma.conf.js'
],

browserify: {
    debug: true,
    transform: ['reactify'],
    bundleDelay: 1000
},

preprocessors: {
    'test/helper/*.js': ['browserify'],
    'test/example/*.spec.js': ['browserify'],
    'test/unit/*.spec.js': ['browserify'],
    'test/integration/*.spec.js': ['browserify'],
    'dev/js/**/*.js': ['browserify']
},

// web server port
port: 9876,

autoWatch: true,

browsers: ['PhantomJS'],

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

plugins: [
    'karma-coverage',
    'karma-mocha',
    'karma-browserify',
    'karma-chai',
    'karma-sinon',
    'karma-phantomjs-launcher'
]```

All files are pre-processed and work correctly using Karma Chrome Launcher, but when I try to start them using PhantomJS, I get a bunch of errors like this:

PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR ReferenceError: Cannot find variable: require in / Users / edwinlin / Documents / repos / Picarus / dev / js / utils / database -utils.js: 1

Thanks for the help!

+4
source share

Source: https://habr.com/ru/post/1599695/


All Articles