Gathering detailed insights and metrics for mochawesome-merge
Gathering detailed insights and metrics for mochawesome-merge
Gathering detailed insights and metrics for mochawesome-merge
Gathering detailed insights and metrics for mochawesome-merge
npm install mochawesome-merge
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
84 Stars
86 Commits
16 Forks
4 Watching
8 Branches
9 Contributors
Updated on 15 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.2%
168,384
Compared to previous day
Last week
1.6%
969,490
Compared to previous week
Last month
1.4%
4,173,950
Compared to previous month
Last year
25.3%
45,550,013
Compared to previous year
Merge several Mochawesome JSON reports
via yarn
:
$ yarn add mochawesome-merge --dev
via npm
:
$ npm install mochawesome-merge --save-dev
1const { merge } = require('mochawesome-merge') 2 3// See Params section below 4const options = { 5 files: [ 6 './report/*.json', 7 8 // you can specify more files or globs if necessary: 9 './mochawesome-report/*.json', 10 ], 11} 12 13merge(options).then(report => { 14 console.log(report) 15})
$ npx mochawesome-merge ./report/*.json -o output.json
or legacy usage
$ npx mochawesome-merge ./report/*.json > output.json
You can specify as many paths as you wish:
$ npx mochawesome-merge ./report/*.json ./mochawesome-report/*.json -o output.json
You can also use a named option for the files like so:
$ npx mochawesome-merge -f ./report/*.json ./mochawesome-report/*.json -o output.json
files
: list of source report file paths. Can include glob patterns.-f | --files
or first positional argument["./mochawesome-report/mochawesome*.json"]
.output
: a file path to the bundled results. Should be a json
file-o | --output
stdout
.Version 4 has come with a breaking change —
it no more accepts params like reportDir
or rootDir
.
Instead, it now accepts a list of file paths or glob patterns
to source report files. If you are migrating to version 4
you likely have to change your params accordignly.
Let's say you have a bunch of reports that you want to merge
under ./mochawesome-report
directory.
Then you're probably using mochawesome-merge like this:
1merge({ 2 reportDir: "mochawesome-report", 3});
After switching to version 4 you need to rename
reportDir
param to files
and change the value to point to your files
rather than the directory:
1merge({ 2- reportDir: "mochawesome-report", 3+ files: ["./mochawesome-report/*.json"], 4})
After upgrading to version 4 all you need
is to remove the --reportDir
option
and instead specify a glob pattern
or several ones if necessary, separating each one with a space:
1- npx mochawesome-merge --reportDir mochawesome-report > mochawesome.json 2+ npx mochawesome-merge ./mochawesome-report/*.json > mochawesome.json
The main motivation to create this library was to be able to use mochawesome together with Cypress.
Since the version 3.0.0
, Cypress runs every spec separately, which leads to generating multiple mochawesome reports, one for each spec. mochawesome-merge
can be used to merge these reports and then generate one HTML report for all your cypress tests.
First, configure cypress.json
:
1{ 2 // use mochawesome reporter as usually 3 "reporter": "mochawesome", 4 "reporterOptions": { 5 // disable overwrite to generate many JSON reports 6 "overwrite": false, 7 // do not generate intermediate HTML reports 8 "html": false, 9 // generate intermediate JSON reports 10 "json": true 11 } 12}
Then, write your custom script to run cypress
together with mochawesome-merge
:
1const cypress = require('cypress') 2const marge = require('mochawesome-report-generator') 3const { merge } = require('mochawesome-merge') 4 5cypress.run().then( 6 () => { 7 generateReport() 8 }, 9 error => { 10 generateReport() 11 console.error(error) 12 process.exit(1) 13 } 14) 15 16function generateReport(options) { 17 return merge(options).then(report => marge.create(report, options)) 18}
Alternatively, you can use CLI to merge JSON reports and generate HTML report.
For example, an AWS CodeBuild buildspec.yml
file might look something like this:
1phases: 2 install: 3 commands: 4 - yarn install 5 build: 6 commands: 7 - yarn cypress run 8 post_build: 9 commands: 10 - yarn mochawesome-merge > mochawesome.json 11 - yarn marge mochawesome.json
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/6 approved changesets -- score normalized to 6
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
42 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