npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mastuff77/junit-report-merger

v3.0.7

Published

Merges multiple JUnit XML reports into one.

Downloads

1

Readme

junit-report-merger

NPM version NPM downloads codecov MIT License

Merges multiple JUnit XML reports into one.

Reporters of many testing frameworks generate JUnit XML reports. mocha-junit-reporter, karma-junit-reporter to name a few. Sometimes there is a need to combine multiple reports together in a single file. This is what junit-report-merger does.

junit-report-merger creates a new test results report in JUnit XML format by collecting all <testsuite> elements from all XML reports and putting them together.

CLI

Package provides a jrm binary, which you can use to merge multiple xml reports into one.
In a nutshell it is a tiny wrapper around mergeFiles api.

Installing

Globally

npm install -g junit-report-merger

In this case you'll be able to execute jrm binary from within your shell.

Locally

npm install junit-report-merger --save-dev

In this case jrm binary will be available only inside package.json scripts:

scripts: {
    "merge-reports": "jrm combined.xml \"results/*.xml\""
}

Usage

Assuming your JUnit test results are in ./results/units/ folder, and you want to get a combined test result file in ./results/combined.xml:

jrm ./results/combined.xml "./results/units/*.xml"

You can also specify multiple glob patterns:

jrm ./results/combined.xml "./results/units/*.xml" "./results/e2e/*.xml"

NOTE
Make sure to wrap each pattern with double quotes ("), otherwise your shell may try to expand it instead of passing to Node.js.

API

Package exports a single object with the following methods.

mergeFiles - Merges contents of multiple XML report files into a single XML report file.

mergeStreams - Merges contents of multiple XML report streams into a single XML report stream.

mergeToString - Merges multiple XML report strings into a single XML report string.

Usage

const path = require('path')
const { mergeFiles } = require('junit-report-merger')

const outputFile = path.join(__dirname, 'results', 'combined.xml')

const inputFiles = ['./results/units/*.xml', './results/e2e/*.xml']

try {
  await mergeFiles(outputFile, inputFiles)
  console.log('Merged, check ./results/combined.xml')
} catch (err) {
  console.error(error)
}

mergeFiles

Signature:

mergeFiles(
    destFilePath: string,
    srcFilePathsOrGlobPatterns: string[],
    options?: MergeFilesOptions
) => Promise<void>

mergeFiles(
    destFilePath: string,
    srcFilePathsOrGlobPatterns: string[],
    options: MergeFilesOptions,
    cb: (err?: Error) => void
) => void

Reads multiple files, merges their contents and write into the given file.

| Param | Type | Description | | -------------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | | destFilePath | string | Where the output should be stored. Denotes a path to file. If file already exists, it will be overwritten. | | srcFilePathsOrGlobPatterns | string[] | Paths to the files which should be merged. You can also specify glob patterns, such as results/**/report-*.xml | | [options] | MergeFilesOptions | Merge options. | | [cb] | (err?: Error) => void | Callback function which will be called at completion. Will receive error as first argument if any. |

Last argument - cb is a Node.js style callback function. If callback function is not passed, function will return a promise. That is, all the following variants will work:

// options passed, callback style
mergeFiles(destFilePath, srcFilePaths, {}, (err) => {})

// options missing, callback style
mergeFiles(destFilePath, srcFilePaths, (err) => {})

// options passed, promise style
await mergeFiles(destFilePath, srcFilePaths, {})

// options missing, promise style
await mergeFiles(destFilePath, srcFilePaths)

MergeFilesOptions

These are the options accepted by mergeFiles.

Signature:

type MergeFilesOptions = {
    onFileMatched? (matchInfo: {
        filePath: string
    }) => void
}

onFileMatched

mergeFiles calls function specified by the onFileMatched option once for each file matched by srcFilePaths, right before file processing begins.

mergeStreams

Signature:

mergeStreams(
    destStream: WritableStream,
    srcStreams: ReadableStream[],
    options?: {}
) => Promise<void>

mergeStreams(
    destStream: WritableStream,
    srcStreams: ReadableStream[],
    options: {},
    cb: (err?: Error) => void
) => void

Reads multiple streams, merges their contents and write into the given stream.

| Param | Type | Description | | ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------- | | destStream | WritableStream | A stream which will be used to write the merge result. | | srcStreams | ReadableStream[] | Streams which will be used to read data from. | | [options] | object | Merge options. Currently unused. | | [cb] | (err?: Error) => void | Callback function which will be called at completion. Will receive error as first argument if any. |

Last argument - cb is a Node.js style callback function. If callback function is not passed, function will return a promise. That is, all the following variants will work:

// options passed, callback style
mergeStreams(destStream, srcStreams, {}, (err) => {})

// options missing, callback style
mergeStreams(destStream, srcStreams, (err) => {})

// options passed, promise style
await mergeStreams(destStream, srcStreams, {})

// options missing, promise style
await mergeStreams(destStream, srcStreams)

mergeToString

Signature:

mergeToString(
    srcStrings: string[],
    options?: {}
) => string

Merges given XML strings and returns the result.

| Param | Type | Description | | ---------- | --------------------- | ----------------------------------- | | srcStrings | string[] | Array of strings to merge together. | | [options] | object | Merge options. Currently unused. |

License

MIT (http://www.opensource.org/licenses/mit-license.php)