Creates a JUnit XML file based on the provided input parameters.
Can be used to create a JUnit XML file from command line, e.g. from a shell script's results. This is great for continuous integration, in case you're running some test steps that don't provide their own JUnit-compatible reporter.
$ npm install --save create-junit-report
const createJunitReport = require('create-junit-report');
createJunitReport('suite', 'class', 'test', false, 'Foo Bar Baz', { outputPath: 'foo' });
//=> creates `foo/suite.xml` file
The generated foo/suite.xml
file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="suite">
<testcase classname="class" name="test">
<failure message="Foo Bar Baz"/>
</testcase>
</testsuite>
</testsuites>
Type: string
Name of the test suite, also the name of the generated file (+ .xml
). Mandatory parameter.
Type: string
Used for the result file's classname
attribute of the testcase entry. Mandatory parameter.
Type: string
Used for the result file's name
attribute of the testcase entry. Mandatory parameter.
Type: boolean
Used to indicate test success (truthy) or test failure (falsy).
Type: string
Optional failure message in case of a test failure.
Type: string
Default: .
Output directory of the generated file.
$ npm install --global create-junit-report
$ create-junit-report --help
Usage
$ create-junit-report [suite] [class] [test] [passed] [failureMessage]
Options
--outputPath path [Default: .]
Examples
$ create-junit-report suite class test 1 --outputPath foo
==> creates `foo/suite.xml`
MIT © Nils Winkler