# cucumber-junit

> Cucumber wrapper that converts the JSON output to JUnitXML

Latest version **1.7.1** (published 2017-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install cucumber-junit
pnpm add cucumber-junit
yarn add cucumber-junit
bun add cucumber-junit
```

Provides the command `cucumber-junit`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2017-12-21 |
| First published | 2014-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | St. John Johnson |
| Maintainers | stjohnjohnson |
| Keywords | cucumber, junit |

## Links

- npm: https://www.npmjs.com/package/cucumber-junit
- Repository: https://github.com/stjohnjohnson/cucumber-junit
- Homepage: https://github.com/stjohnjohnson/cucumber-junit#readme
- Issues: https://github.com/stjohnjohnson/cucumber-junit/issues
- npm.io page: https://npm.io/package/cucumber-junit

## Dependencies (2)

- [xml](https://npm.io/package/xml.md) 0.0.12
- [yargs](https://npm.io/package/yargs.md) ^5.0.0

## Recent versions

- 1.7.1 (latest) — 2017-12-21
- 1.7.0 — 2017-03-02
- 1.6.0 — 2016-08-31
- 1.5.0 — 2016-02-14
- 1.4.1 — 2016-02-03
- 1.4.0 — 2015-10-27
- 1.3.1 — 2015-09-11
- 1.3.0 — 2015-07-17
- 1.2.0 — 2015-07-10
- 1.1.10 — 2015-01-27
- 1.1.9 — 2014-09-03
- 1.1.8 — 2014-08-16
- 1.1.7 — 2014-07-09
- 1.1.6 — 2014-07-02
- 1.1.5 — 2014-05-20
- … 4 more at https://npm.io/package/cucumber-junit/versions

## README

# cucumber-junit

[![wercker status](https://app.wercker.com/status/a4b60396ae8a91bf223f44cdac8e09df/m "wercker status")](https://app.wercker.com/project/bykey/a4b60396ae8a91bf223f44cdac8e09df)

Converts CucumberJS JSON output into JUnitXML for software like Jenkins to read.

## Install

cucumber-junit should be added to your test codebase as a dev dependency.  You can do this with:

``` shell
$ npm install --save-dev cucumber-junit
```

Alternatively you can manually add it to your package.json file:

``` json
{
  "devDependencies" : {
    "cucumber-junit": "latest"
  }
}
```

then install with:

``` shell
$ npm install --dev
```

## Run

cucumber-junit should be appended to your existing Cucumber.JS commands

``` shell
$ node_modules/.bin/cucumber-js --format=json | node_modules/.bin/cucumber-junit > output_JUnit.xml
```

The following options are supported by `lib/cucumber_junit`:

* strict - if true, pending or undefined steps will be reported as failures
* indent - passed to the [XML formatter][XML], defaults to 4 spaces
* stream - passed to the [XML formatter][XML] to return the result as a stream
* declaration - passed to the [XML formatter][XML]
* prefix - added to each test suite name (if test are executed against multiple browsers/devices)

These options can be specified on the command line when calling `.bin/cucumber-junit`:

* `-s` or `--strict`
* `-i 4` or `--indent 4` 
* `-e UTF-8` or `--encoding "UTF-*"` - applied to the XML declaration 

## Gulp

cucumber-junit can be called from [Gulp](http://gulpjs.com/):

```javascript
gulp.task('cucumber:report', ['cucumber'], function() {
    gulp.src('test-reports/cucumber.json')
        .pipe(cucumberXmlReport({strict: true}))
        .pipe(gulp.dest('test-reports'));
});

function cucumberXmlReport(opts) {
    var gutil = require('gulp-util'),
        through = require('through2'),
        cucumberJunit = require('cucumber-junit');
    
    return through.obj(function (file, enc, cb) {
        // If tests are executed against multiple browsers/devices
        var suffix = file.path.match(/\/cucumber-?(.*)\.json/);
        if (suffix) {
            opts.prefix = suffix[1] + ';';
        }
        
        var xml = cucumberJunit(file.contents, opts);
        file.contents = new Buffer(xml);
        file.path = gutil.replaceExtension(file.path, '.xml');
        cb(null, file);
    });
}
```

## License

[MIT](http://opensource.org/licenses/MIT) © [St. John Johnson](http://stjohnjohnson.com)
[XML]: https://www.npmjs.com/package/xml#options

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