Jalayn
Jalayn

Reputation: 9274

Mocha reporter does not seem to be taken into account when tests ran by chimp

I have a very simple project that contains a package.json with this:

{
  "scripts": {
    "acceptance": "chimp --mocha --mochaReporter=mocha-junit-reporter  --chai --browser=chrome --path=src/spec/acceptance/**"
   },
  "devDependencies": {
  "chai": "^3.5.0",
  "chimp": "^0.47.1",
  "mocha": "^3.2.0",
  "mocha-junit-reporter": "^1.13.0",
  "uglify-js": "^2.7.5",
  "webdriverio": "^4.6.2"
},
  "dependencies": {}
}

To execute the tests, I'm running the following command:

npm run-script acceptance

Which makes chimp execute the tests with mocha (those are webdriverio tests, hence why I am using chimp) The tests run as intended, however, there isn't any test-results.xml produced and the test results show up in the default "spec" format.

As suggested in the documentation, I tried different alternatives such as creating a chimp.js file at the root of the project, that contains the following:

{
  mochaCommandLineOptions: ['--reporter mocha-junit-reporter'];
  mochaConfig: { reporter: 'mocha-junit-reporter' };
  mochaReporter: "mocha-junit-reporter";
}

But neither of these options seem to be taken into account.

So, anyone can tell me if I am doing something wrong?

ps: I have a separate unit testing script that works fine, and where custom reporting is taken into account, but for those, I'm simply using mocha without chimp.

Upvotes: 0

Views: 758

Answers (1)

Xolv.io
Xolv.io

Reputation: 2533

Try this in your chimp.js config file:

  mocha: true,
  chai: true,
  path: 'src/spec/acceptance/**',
  mochaConfig: {
    reporter: 'mocha-junit-reporter',
    reporterOptions: {
      mochaFile: './test-results.xml'
    }
  }

Upvotes: 1

Related Questions