0
votes

I am setting up nyc/mocha for my project. I want to pass --exit option to mocha when running mocha with/without nyc.

Here's my packages.json:

"scripts": {
    "start": "node ./app",
    "test": "./node_modules/.bin/mocha --exit",
    "test-with-coverage": "nyc --reporter=html mocha --reporter mochawesome --exit",
    "apidoc": "apidoc -i routes/ -o apidocs/"
  }

But this throws invalid option error when I run npm test or npm run test-with-coverage.

How do you pass any options to mocha from npm?

1
no so sure, but isnt there to times -- in your command (after html mocha)hereandnow78
Even after removing -- it doesn't work.Sumit Jain
You did try exaclty this nyc --reporter=html mocha -- --reporter mochawesome ?Orelsanpls

1 Answers

1
votes

The only reason I can see for having the problem with the code you show is that --exit was added in Mocha 4.0.0 and you happen to be using an older version.