I am sure I am missing something obvious here!
I have read the instructions here (https://github.com/visionmedia/mocha/wiki/Third-party-reporters), and have taken their code and added as a new node module (i.e. it is within node_modules/my-reporter/reporter.js
). However, I can't seem to get mocha to load this reporter.
I have tried numerous variations …
mocha allTests.js -R ./node_modules/my-reporter/reporter.js
mocha allTests.js -R my-reporter
But nothing works :-(
I can successfully load my reporter within a JS file:
my_reporter = require('./node_modules/my-reporter/reporter.js')
console.log(my_reporter);
Has anyone got any hints?
u should provide the reporter like this:
mocha allTests.js -R './node_modules/my-reporter/reporter'
You should not provide the .js file extension as that is the normal convention for including modules.
It appears that if mocha is installed globally (which I believe it almost always is), you have to install your reporter the same way.
If you don't want to publish the reporter as a public module, you can just:
npm pack
npm install /path/to/your/module.gz -g
I've tried putting the reporter everywhere else that would make sense, but was getting "invalid reporter" unless it was installed globally.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With