Gathering detailed insights and metrics for mocha-multi-reporters
Gathering detailed insights and metrics for mocha-multi-reporters
Gathering detailed insights and metrics for mocha-multi-reporters
Gathering detailed insights and metrics for mocha-multi-reporters
Generate multiple mocha reports in a single mocha execution.
npm install mocha-multi-reporters
80.6
Supply Chain
98.9
Quality
75.7
Maintenance
100
Vulnerability
98.9
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
74 Stars
254 Commits
22 Forks
3 Watching
6 Branches
15 Contributors
Updated on 01 Jul 2024
Minified
Minified + Gzipped
JavaScript (99.74%)
Shell (0.26%)
Cumulative downloads
Total Downloads
Last day
-10.4%
77,408
Compared to previous day
Last week
-0.7%
470,435
Compared to previous week
Last month
12.4%
2,006,456
Compared to previous month
Last year
17.4%
21,680,970
Compared to previous year
1
Generate multiple mocha reports in a single mocha execution.
This is functionally the same as cypress-multi-reporters
; this is the ongoing fork.
npm install mocha-multi-reporters --save-dev
https://github.com/stanleyhlng/mocha-multi-reporters-demo
1$ ./node_modules/.bin/mocha --reporter mocha-multi-reporters 2 mocha-test #1 3 ✓ sample test #1.1 4 ✓ sample test #1.2 5 6 mocha-test #2 7 ✓ sample test #2.1 8 - sample test #2.2 9 10 11 3 passing (6ms) 12 1 pending 13 14<testsuite name="Mocha Tests" tests="4" failures="0" errors="0" skipped="1" timestamp="Sun, 03 Jan 2016 08:15:14 GMT" time="0.005"> 15<testcase classname="mocha-test #1" name="sample test #1.1" time="0"/> 16<testcase classname="mocha-test #1" name="sample test #1.2" time="0"/> 17<testcase classname="mocha-test #2" name="sample test #2.1" time="0"/> 18<testcase classname="mocha-test #2" name="sample test #2.2" time="0"><skipped/></testcase> 19</testsuite>
Set the reporters configuration using --reporter-options configFile=config.json
.
reporterEnabled
as a comma-delimited list
1{ 2 "reporterEnabled": "spec, @my-org/custom" 3}
reporterOptions
, as key.
For scoped reporters such as example @myorg/custom, remove all special characters.
1{ 2 "reporterEnabled": "spec, @my-org/custom", 3 "myOrgCustomReporterOptions": { 4 // [...] 5 } 6}
spec
and json
reports.1// File: config.json 2{ 3 "reporterEnabled": "spec, json" 4}
1$ ./node_modules/.bin/mocha --reporter mocha-multi-reporters --reporter-options configFile=config.json 2 mocha-test #1 3 ✓ sample test #1.1 4 ✓ sample test #1.2 5 6 mocha-test #2 7 ✓ sample test #2.1 8 - sample test #2.2 9 10 11 3 passing (6ms) 12 1 pending 13 14{ 15 "stats": { 16 "suites": 2, 17 "tests": 4, 18 "passes": 3, 19 "pending": 1, 20 "failures": 0, 21 "start": "2015-12-30T22:49:39.713Z", 22 "end": "2015-12-30T22:49:39.717Z", 23 "duration": 4 24 }, 25 "tests": [ 26 { 27 "title": "sample test #1.1", 28 "fullTitle": "mocha-test #1 sample test #1.1", 29 "duration": 1, 30 "err": {} 31 }, 32 { 33 "title": "sample test #1.2", 34 "fullTitle": "mocha-test #1 sample test #1.2", 35 "duration": 0, 36 "err": {} 37 }, 38 { 39 "title": "sample test #2.1", 40 "fullTitle": "mocha-test #2 sample test #2.1", 41 "duration": 0, 42 "err": {} 43 }, 44 { 45 "title": "sample test #2.2", 46 "fullTitle": "mocha-test #2 sample test #2.2", 47 "err": {} 48 } 49 ], 50 "pending": [ 51 { 52 "title": "sample test #2.2", 53 "fullTitle": "mocha-test #2 sample test #2.2", 54 "err": {} 55 } 56 ], 57 "failures": [], 58 "passes": [ 59 { 60 "title": "sample test #1.1", 61 "fullTitle": "mocha-test #1 sample test #1.1", 62 "duration": 1, 63 "err": {} 64 }, 65 { 66 "title": "sample test #1.2", 67 "fullTitle": "mocha-test #1 sample test #1.2", 68 "duration": 0, 69 "err": {} 70 }, 71 { 72 "title": "sample test #2.1", 73 "fullTitle": "mocha-test #2 sample test #2.1", 74 "duration": 0, 75 "err": {} 76 } 77 ] 78}%
tap
and xunit
reports.1// File: config.json 2{ 3 "reporterEnabled": "tap, xunit", 4 "xunitReporterOptions": { 5 "output": "xunit-custom.xml" 6 } 7}
1$ ./node_modules/.bin/mocha --reporter mocha-multi-reporters --reporter-options configFile=config.json 2 31..4 4ok 1 mocha-test 1 sample test 1.1 5ok 2 mocha-test 1 sample test 1.2 6ok 3 mocha-test 2 sample test 2.1 7ok 4 mocha-test 2 sample test 2.2 # SKIP - 8# tests 3 9# pass 3 10# fail 0 11 12$ cat xunit-custom.xml 13<testsuite name="Mocha Tests" tests="4" failures="0" errors="0" skipped="1" timestamp="Sun, 03 Jan 2016 08:02:24 GMT" time="0.006"> 14<testcase classname="mocha-test #1" name="sample test #1.1" time="0.001"/> 15<testcase classname="mocha-test #1" name="sample test #1.2" time="0.001"/> 16<testcase classname="mocha-test #2" name="sample test #2.1" time="0"/> 17<testcase classname="mocha-test #2" name="sample test #2.2" time="0"><skipped/></testcase> 18</testsuite>
tap
and junit
reports.To generate junit
report, we are using mocha-junit-reporter.
1$ npm install mocha-junit-reporter
1// File: config.json 2{ 3 "reporterEnabled": "mocha-junit-reporter", 4 "mochaJunitReporterReporterOptions": { 5 "mochaFile": "junit-custom.xml" 6 } 7}
1$ ./node_modules/.bin/mocha --reporter mocha-multi-reporters --reporter-options configFile=config.json 2 31..4 4ok 1 mocha-test 1 sample test 1.1 5ok 2 mocha-test 1 sample test 1.2 6ok 3 mocha-test 2 sample test 2.1 7ok 4 mocha-test 2 sample test 2.2 # SKIP - 8# tests 3 9# pass 3 10# fail 0 11 12$ cat xunit-custom.xml 13<?xml version="1.0" encoding="UTF-8"?> 14<testsuites name="Mocha Tests" time="0.001" tests="4" failures="0" skipped="1"> 15 <testsuite name="Root Suite" timestamp="2016-10-30T02:27:54" tests="0" failures="0" time="0"> 16 </testsuite> 17 <testsuite name="mocha-test #1" timestamp="2016-10-30T02:27:54" tests="2" failures="0" time="0.001"> 18 <testcase name="mocha-test #1 sample test #1.1" time="0.001" classname="sample test #1.1"> 19 </testcase> 20 <testcase name="mocha-test #1 sample test #1.2" time="0" classname="sample test #1.2"> 21 </testcase> 22 </testsuite> 23 <testsuite name="mocha-test #2" timestamp="2016-10-30T02:27:54" tests="2" failures="0" time="0"> 24 <testcase name="mocha-test #2 sample test #2.1" time="0" classname="sample test #2.1"> 25 </testcase> 26 </testsuite> 27</testsuites>
mmrOutput
optionThis option lets you dynamically replace the output files of reporter options.
In your Mocha --reporterOptions
, specify mmrOutput
with a plus-sign-separated
list of the reporter name, the property on that reporter's options to have replaced, and the dynamic ID you would like substituted. If you need multiple reporters
to have dynamic output, add additional plus-sign-separated lists separated by colons.
1mocha --reporter mocha-multi-reporters --reporterOptions configFile=mocha-multi-reporters.json,mmrOutput=@mochajs/json-file-reporter+output+specialID tests
1// mocha-multi-reporters.json 2{ 3 "mochajsJsonFileReporterReporterOptions": { 4 "output": "tests/results/file-{id}.json" 5 }, 6 "reporterEnabled": "spec, @mochajs/json-file-reporter" 7}
This will produce an output
for @mochajs/json-file-reporter
reporterOptions
with the value:
tests/results/file-specialID.json
Note: cmrOutput
is also supported for compatibility with the cypress-multi-reporters
.
Note that when Mocha is called programmatically, it is passed an options object when created. This object is usually derived from a config file that your mocha test runner reads prior to instantiation. This is the object that must contain a key reporter
with a value of mocha-multi-reporters
for this plugin to be used. You can also pass the key reporterOptions
with a value of any of the above listed config files (including the reporterEnabled
subkey and any other plugin configuration information.) This removes the requirement to have an intermediate configuration file specifically for the multireporter configuration.
1const mocha = new Mocha({
2 reporter: "mocha-multi-reporters",
3 timeout: config.testTimeout || 60000,
4 slow: config.slow || 10000,
5 reporterOptions: {
6 "reporterEnabled": "mocha-junit-reporter, tap",
7 "mochaJunitReporterReporterOptions": {
8 "mochaFile": "junit-custom.xml"
9 }
10 }
11 });
12 mocha.addFile(...)
13 mocha.run(...)
14
Note that it will first check if reporterOptions contains a configFile
key, and if it does, use that. That key must not exist in the reporterOptions
object in order to pass these values in directly.
The MIT License (MIT)
Copyright(c) 2019 Yousaf Nabi Copyright(c) 2017 Stanley Ng
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/6 approved changesets -- score normalized to 1
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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