简体   繁体   中英

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.

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'
    }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM