How to create a custom reporter using Mocha

I'm sure something is not so obvious with me!

I read the instructions here ( https://github.com/visionmedia/mocha/wiki/Third-party-reporters ), and took my code and added as a new node module (i.e. it is within node_modules/my-reporter/reporter.js). However, I cannot get mocha to download this reporter.

I tried many variations ...

mocha allTests.js -R ./node_modules/my-reporter/reporter.js

mocha allTests.js -R my-reporter

But nothing works: - (

I can successfully upload my reporter to a JS file:

my_reporter = require('./node_modules/my-reporter/reporter.js')
console.log(my_reporter);

Does anyone have any clues?

+4
source share
2 answers

It seems that if mocha is installed globally (which I think is almost always there), you need to install the reporter in the same way.

, :

npm pack
npm install /path/to/your/module.gz -g

, , " ", .

+3

u :

mocha allTests.js -R './node_modules/my-reporter/reporter'

.js, .

+6

Source: https://habr.com/ru/post/1523801/


All Articles