# mochawesome-merge

> Merge several Mochawesome JSON reports

Latest version **5.1.1** (published 2026-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install mochawesome-merge
pnpm add mochawesome-merge
yarn add mochawesome-merge
bun add mochawesome-merge
```

Provides the command `mochawesome-merge`.

## Health

**Score 50/100 (C)** — status: stable.

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 5.1.1 |
| Published | 2026-02-06 |
| First published | 2018-12-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=22 |
| Dependencies | 3 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 83 |
| Author | Anton Telesh |
| Maintainers | antontelesh |

## Links

- npm: https://www.npmjs.com/package/mochawesome-merge
- Repository: https://github.com/Antontelesh/mochawesome-merge
- Homepage: https://github.com/Antontelesh/mochawesome-merge#readme
- Issues: https://github.com/Antontelesh/mochawesome-merge/issues
- npm.io page: https://npm.io/package/mochawesome-merge

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^13.0.1
- [yargs](https://npm.io/package/yargs.md) ^17.7.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.0

## Recent versions

- 5.1.1 (latest) — 2026-02-06
- 5.1.0 — 2025-11-25
- 5.0.0 — 2025-01-29
- 4.4.1 — 2025-01-29
- 4.4.0 — 2025-01-27
- 4.3.0 — 2023-03-13
- 4.2.2 — 2022-12-09
- 4.2.1 — 2021-12-03
- 4.2.0 — 2020-09-23
- 4.1.0 — 2020-06-02
- 4.0.3 — 2020-03-14
- 4.0.2 — 2020-03-02
- 4.0.1 — 2020-02-19
- 4.0.0 — 2019-12-26
- 3.0.0 — 2019-12-24
- … 11 more at https://npm.io/package/mochawesome-merge/versions

## README

# mochawesome-merge

[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Merge several [Mochawesome](https://github.com/adamgruber/mochawesome) JSON reports

## Installation

```
$ npm install mochawesome-merge --save-dev
```

## Examples

### JavaScript API

```javascript
const { merge } = require('mochawesome-merge')

// See Params section below
const options = {
  files: [
    './report/*.json',

    // you can specify more files or globs if necessary:
    './mochawesome-report/*.json',
  ],
}

merge(options).then(report => {
  console.log(report)
})
```

### CLI

```
$ 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
```

### Params

- `files`: list of source report file paths. Can include glob patterns.
- Aliases: `-f | --files` or first positional argument
- Defaults to `["./mochawesome-report/mochawesome*.json"]`.
#
- `output`: a file path to the bundled results. Should be a `json` file 
- Aliases: `-o | --output`
- Defaults to `stdout`.

## Migration to v4

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.

### JavaScript API

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:

```js
merge({
  reportDir: "mochawesome-report",
});
```

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:

```diff
merge({
-  reportDir: "mochawesome-report",
+  files: ["./mochawesome-report/*.json"],
})
```

### CLI

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:

```diff
- npx mochawesome-merge --reportDir mochawesome-report > mochawesome.json
+ npx mochawesome-merge ./mochawesome-report/*.json > mochawesome.json
```

## [Cypress](https://github.com/cypress-io/cypress)

The main motivation to create this library was to be able to use [mochawesome](https://github.com/adamgruber/mochawesome) together with [Cypress](https://github.com/cypress-io/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`:

```jsonc
{
  // use mochawesome reporter as usually
  "reporter": "mochawesome",
  "reporterOptions": {
    // disable overwrite to generate many JSON reports
    "overwrite": false,
    // do not generate intermediate HTML reports
    "html": false,
    // generate intermediate JSON reports
    "json": true
  }
}
```

Then, write your custom script to run `cypress` together with `mochawesome-merge`:

```javascript
const cypress = require('cypress')
const marge = require('mochawesome-report-generator')
const { merge } = require('mochawesome-merge')

cypress.run().then(
  () => {
    generateReport()
  },
  error => {
    generateReport()
    console.error(error)
    process.exit(1)
  }
)

function generateReport(options) {
  return merge(options).then(report => marge.create(report, options))
}
```

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:

```yaml
phases:
  install:
    commands:
      - npm ci
  build:
    commands:
      - npm run cypress
  post_build:
    commands:
      - npm run mochawesome-merge > mochawesome.json
      - npm run marge mochawesome.json
```

---
_Source: https://npm.io/package/mochawesome-merge · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
