0

When I launch my tests with ./node_modules/.bin/cucumberjs tests/features they run ok, but when I launch tests with npm test I get the following error:

20 06 2016 10:40:37.610:INFO [Firefox 44.0.0 (Ubuntu 0.0.0)]: Connected on socket /#0o9c3SofFmLLUL3AAAAB with id 99491078
    Firefox 44.0.0 (Ubuntu 0.0.0) ERROR
      ReferenceError: setImmediate is not defined
      at node_modules/cucumber/release/cucumber.js:211

Does somebody has an idea of what is happening?

This is my package.json file:

{
  "name": "...",
  "version": "1.0.0",
  "description": "...",
  "main": "googlemappers.js",
  "devDependencies": {
    "chai": "^3.5.0",
    "cucumber": "^0.10.4",
    "jquery": "^3.0.0",
    "karma": "^0.13.22",
    "karma-chai": "^0.1.0",
    "karma-cucumber-js": "^0.2.0",
    "karma-firefox-launcher": "^1.0.0",
    "karma-mocha": "^1.0.1",
    "mocha": "^2.5.3"
  },
  "scripts": {
    "test": "karma start karma.conf.js"
  },
  "repository": {
    "type": "git",
    "url": "..."
  },
  "author": "...",
  "license": "",
  "homepage": "..."
}
  },

And this is my karma.conf.js:

module.exports = function(config) {
  config.set({
    basePath: '',
    frameworks: [
        'mocha',
        'chai',
        'cucumber-js'
    ],
    files: [
        'src/*.js',
        'tests/features/*.feature'
    ],
    exclude: [
    ],
    preprocessors: {
    },
    reporters: ['progress'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Firefox'],
    singleRun: false,
    concurrency: Infinity
  })
}
Alvaro Maceda
  • 604
  • 1
  • 7
  • 21

1 Answers1

0

Downgrading Cucumber to 0.10.3 (w/o leading caret, as there apparently is a breaking change between 0.10.3 and 0.10.4) fixed the issue for me.

bengee
  • 1
  • 2
  • You will probably still run into errors further down the line, though. I could not get `karma-cucumber-js` to work in PhantomJS or Firefox. Only Chrome did not complain about an undefined `Error.captureStackTrace` (see also https://github.com/cucumber/cucumber-js/issues/538 where they acknowledge the issue for FF) – bengee Jun 21 '16 at 07:09
  • Adding the patch/polyfill for `Error.captureStackTrace` from [1] to the step definitions file fixes the FF and PhantomJS issues. [1] https://github.com/babel/babel/blob/719d23eb3b94598a0ba41f339b52d54d2395b99f/lib/6to5/browser.js – bengee Jun 21 '16 at 08:06