Gathering detailed insights and metrics for cypress-multi-reporters
Gathering detailed insights and metrics for cypress-multi-reporters
Gathering detailed insights and metrics for cypress-multi-reporters
Gathering detailed insights and metrics for cypress-multi-reporters
npm install cypress-multi-reporters
Typescript
Module System
Min. Node Version
Node Version
NPM Version
Release v2.0.5
Updated on Jan 27, 2025
Release v2.0.4
Updated on Oct 25, 2024
Release v1.5.4 - cypress-slack-reporter
Updated on Oct 24, 2024
Release v2.0.3 - cypress-multi-reporters
Updated on Oct 24, 2024
Release v1.6.4
Updated on Oct 24, 2023
Release v1.6.3
Updated on Mar 13, 2023
JavaScript (58.45%)
TypeScript (22.32%)
HTML (8.83%)
Shell (4.83%)
Gherkin (1.72%)
Dockerfile (1.59%)
Makefile (1.21%)
MDX (0.69%)
CSS (0.36%)
Total Downloads
128,937,961
Last Day
40,764
Last Week
910,871
Last Month
3,932,271
Last Year
42,027,468
MIT License
170 Stars
1,218 Commits
47 Forks
1 Watchers
4 Branches
12 Contributors
Updated on Feb 23, 2025
Minified
Minified + Gzipped
Latest Version
2.0.5
Package Id
cypress-multi-reporters@2.0.5
Unpacked Size
27.65 kB
Size
7.48 kB
File Count
7
NPM Version
10.8.2
Node Version
20.18.1
Published on
Jan 27, 2025
Cumulative downloads
Total Downloads
Last Day
-1%
40,764
Compared to previous day
Last Week
-4.5%
910,871
Compared to previous week
Last Month
3.1%
3,932,271
Compared to previous month
Last Year
24.7%
42,027,468
Compared to previous year
1
Generate multiple mocha reports in a single mocha execution.
npm install cypress-multi-reporters --save-dev
https://github.com/stanleyhlng/mocha-multi-reporters-demo
1$ ./node_modules/.bin/mocha --reporter cypress-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
.
Include reporters in reporterEnabled
as a comma-delimited list
1{ 2 "reporterEnabled": "spec, @my-org/custom" 3}
Specify each reporter's configuration using its camel-cased name, followed by 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}
You can also use a .js
file to use Javascript logic to configure the reporters.
Ex:
1// Set the reporters configuration using `--reporter-options configFile=reporterConfig.js`. 2 3// In reporterConfig.js 4const locale = process.env.SITE_LOCALE; 5 6module.exports = { 7 "reporterEnabled": "mochawesome, mocha-junit-reporter", 8 "mochawesomeReporterOptions": { 9 "reportDir": `.reports/${locale}` 10 }, 11 "mochaJunitReporterReporterOptions": { 12 "mochaFile": `./junit/${locale}/[hash].xml` 13};
This is useful, for example, if you need to run CI jobs on multiple sites using a script like:
1 #!/bin/bash 2 # By default run on all sites but you can pass paramenters to run on other sites 3 args="$@" 4 allsites="US UK AU" 5 sites=${args:-$allsites} 6 7 echo "Will run on $sites" 8 9 success=0 10 for site in $sites 11 do 12 echo "Running on $site" 13 export SITE_LOCALE="$site" 14 npx cypress run --reporter-options configFile=reporterConfig.js 15 ret_code=$? 16 if [ $ret_code -ne 0 ]; then 17 echo "Run for $site - Exited with an ERROR: $ret_code" 18 success=$ret_code 19 fi 20 done 21 echo "All sites finished running. Exiting with $success" 22 exit $success
spec
and json
reports.1// File: config.json 2{ 3 "reporterEnabled": "spec, json" 4}
1$ ./node_modules/.bin/mocha --reporter cypress-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 cypress-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 cypress-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>
cmrOutput
optionThis option lets you dynamically replace the output files of reporter options.
In your Mocha --reporterOptions
, specify cmrOutput
with a plug-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 cypress-multi-reporters --reporterOptions configFile=cypress-multi-reporters.json,cmrOutput=@mochajs/json-file-reporter+output+specialID tests
1// cypress-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 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 cypress-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: "cypress-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.
No security vulnerabilities found.