Gathering detailed insights and metrics for mocha-multi
Gathering detailed insights and metrics for mocha-multi
Gathering detailed insights and metrics for mocha-multi
Gathering detailed insights and metrics for mocha-multi
A bit of a hack to get multiple reporters working with mocha
npm install mocha-multi
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
76 Stars
200 Commits
22 Forks
7 Watching
13 Branches
15 Contributors
Updated on 07 Nov 2023
JavaScript (71.62%)
Shell (28.38%)
Cumulative downloads
Total Downloads
Last day
-6.9%
18,120
Compared to previous day
Last week
4.9%
92,663
Compared to previous week
Last month
4.8%
376,748
Compared to previous month
Last year
9.8%
4,484,731
Compared to previous year
5
1
A bit of a hack to get multiple reporters working with mocha
npm install mocha-multi --save-dev
mocha --reporter mocha-multi
For both methods below, the special value of -
(hyphen) for destination uses normal stdout/stderr.
multi
Environment VariableSet the environment variable multi
to whitespace-separated type=destination pairs.
1multi='dot=- xunit=file.xml doc=docs.html' mocha -R mocha-multi
--reporter-options
Pass --reporter-options
with comma-separated type=destination pairs.
1mocha -R mocha-multi --reporter-options dot=-,xunit=file.xml,doc=docs.html
Using either of the above methods, include a type=destination pair where the type is mocha-multi and the destination is a filename, e.g. mocha-multi=mocha-multi-reporters.json
More reporters will be loaded from the named file, which must be valid JSON in the same data format described below for passing reporterOptions to Mocha programmatically.
You may specify the desired reporters (and their options) by passing reporterOptions
to the Mocha contructor.
For example: the following config is the equivalent of setting multi='spec=- Progress=/tmp/mocha-multi.Progress.out'
, with the addition of passing the verbose: true
option to the Progress reporter.
1var reporterOptions = { 2 Progress: { 3 stdout: "/tmp/mocha-multi.Progress.out", 4 options: { 5 verbose: true 6 } 7 }, 8 spec: "-" 9}; 10 11var mocha = new Mocha({ 12 ui: "bdd" 13 reporter: "mocha-multi", 14 reporterOptions: reporterOptions 15}); 16mocha.addFile("test/dummy-spec.js"); 17mocha.run(function onRun(failures){ 18 console.log(failures); 19});
The options will be passed as the second argument to the reporter constructor.
A big hack that keeps changing the value of process.stdout and process.stderr whenever a reporter is doing its thing.
Yeah, Sorry!
This is very hacky, specifically:
process
and console
objects get their internal state messed withprocess.exit
is hacked to wait for streams to finish writingNow that https://github.com/mochajs/mocha/pull/1059 is released the process.exit hack could maybe be tidier
Having each reporter run in a child process would make it eaiser to capture their streams, but might lead to other issues
The breaking changes are mostly around internals, and shouldn't affect most people.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/18 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More