{"_id":"@128technology/mocha-junit-reporter","_rev":"1-b3495e5f3ef46ba3253cec5d08e87891","name":"@128technology/mocha-junit-reporter","dist-tags":{"latest":"2.0.0"},"versions":{"2.0.0":{"name":"@128technology/mocha-junit-reporter","version":"2.0.0","description":"A JUnit reporter for mocha.","main":"index.js","scripts":{"ci":"npm run lint && npm run test","lint":"eslint '*.js' 'test/**/*.js'","test":"MOCHA_FILE=test/mocha.xml node_modules/.bin/mocha test --reporter=spec","tdd":"MOCHA_FILE=test/mocha.xml node_modules/.bin/mocha test --reporter=min --watch"},"repository":{"type":"git","url":"git+https://github.com/michaelleeallen/mocha-junit-reporter.git"},"keywords":["mocha","junit","reporter"],"author":{"name":"Michael Allen","email":"michael.lee.allen@gmail.com"},"license":"MIT","devDependencies":{"chai":"^3.0.0","chai-xml":"^0.3.0","eslint":"^7.0.0","mocha":"^7.2.0","rimraf":"^3.0.2","test-console":"^1.0.0","xmllint":"^0.1.1"},"dependencies":{"debug":"^2.2.0","md5":"^2.1.0","mkdirp":"~0.5.1","strip-ansi":"^4.0.0","xml":"^1.0.0"},"peerDependencies":{"mocha":">=2.2.5"},"gitHead":"2afddcf93f70c018086406b0f98d14a8836ab3ab","bugs":{"url":"https://github.com/michaelleeallen/mocha-junit-reporter/issues"},"homepage":"https://github.com/michaelleeallen/mocha-junit-reporter#readme","_id":"@128technology/mocha-junit-reporter@2.0.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-7fgu09rdi0ZrdsQn9tIagEUaXAtktl0U97ipyDAyRpbKb9geiU2KGcx74cdm/sZHQYyjhhN38t8ig6rzrZpicg==","shasum":"91eb0ad704dac5d2785f6dfcd5d10c4c25f28f6c","tarball":"https://registry.npmjs.org/@128technology/mocha-junit-reporter/-/mocha-junit-reporter-2.0.0.tgz","fileCount":12,"unpackedSize":72367,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbivrCRA9TVsSAnZWagAAetwP/2jqYAWU0tELnbyn6ztC\n1XQX91gbnRrq0U4a5iefEBJMot3pJtySDOOIa8bjVxrPcTIGWhib9Tdhhlhs\nb02x+Po9HFf8meILjTRj4rAcIPZoH6V8A4zcNvoxdAocEpdex5zHaC+MsnFf\nLBhLIHiPD7/C5zTq8dP6B5rQUgbR3e02roItODS4erLNVKeEgcJUi/vkaQz+\nCR62KhY1806qgD++/WKmgeVum9lz+YljWY05eNpKtU04w5zOgZuCyojUYUoz\ntN2qxzTWMTd3ep8JaNx95BMrz41k2+lf8QA7lTT3CsUhoyT4GK1vNZ2Y3JD8\n2jRlr6boQw4U27dPvAU9HYnYUoCnkhKwrmteGcC80oSMWzCIFLjQoC/BtplG\nNMPogayf/9uGW5bnc51PlcIcW7NmeodeCGZEKdwHoOBFXE6Y5q+7qlkil+KO\nZGvlfYDupCdcq1Co7tLXq45xpPsPBm66OvVs7LFHzMlvwD/2R6lEMzWgvSdb\nXzi9qTULQ4OypTB97MDEN8UY3dc/fEfA3Mxb+ZAwXS7BcaTpK1TZtAqXUz7i\n/gCrRrCmd0VvWAhnOdJCxyEsRMqd9YJOu4H4G5p3svaceqQd7liVht7IF0zC\nGIWwAtPpCsT8XQK8U2EPOzGMgmKc3SdmGw+udZIJtBqyzpF3xpPzi/J5ONmS\n7Urc\r\n=fMuQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB6bFD+GFzHhhujtJs+v4fgrqOhd6SXav4kK7c28kxo8AiEAuFVziTAgY02OKryGkH0NwBKrSzHwteiO57YdYKdzLKs="}]},"maintainers":[{"name":"benbeshel","email":"benbeshel@gmail.com"},{"name":"thedillonb","email":"thedillonb@gmail.com"},{"name":"cmain","email":"cmain@128technology.com"},{"name":"128dbuchanan","email":"dbuchanan@128technology.com"},{"name":"128techadmin","email":"opensource@128technology.com"}],"_npmUser":{"name":"128techadmin","email":"opensource@128technology.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocha-junit-reporter_2.0.0_1601055723432_0.5180669345357869"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-25T17:42:03.269Z","2.0.0":"2020-09-25T17:42:03.597Z","modified":"2022-04-04T10:31:11.815Z"},"maintainers":[{"name":"benbeshel","email":"benbeshel@gmail.com"},{"name":"thedillonb","email":"thedillonb@gmail.com"},{"name":"cmain","email":"cmain@128technology.com"},{"name":"128dbuchanan","email":"dbuchanan@128technology.com"},{"name":"128techadmin","email":"opensource@128technology.com"}],"description":"A JUnit reporter for mocha.","homepage":"https://github.com/michaelleeallen/mocha-junit-reporter#readme","keywords":["mocha","junit","reporter"],"repository":{"type":"git","url":"git+https://github.com/michaelleeallen/mocha-junit-reporter.git"},"author":{"name":"Michael Allen","email":"michael.lee.allen@gmail.com"},"bugs":{"url":"https://github.com/michaelleeallen/mocha-junit-reporter/issues"},"license":"MIT","readme":"# JUnit Reporter for Mocha\n\n[![Build Status][travis-badge]][travis-build]\n[![npm][npm-badge]][npm-listing]\n\nProduces JUnit-style XML test results.\n\n## Installation\n\n```shell\n$ npm install mocha-junit-reporter --save-dev\n```\n\nor as a global module\n```shell\n$ npm install -g mocha-junit-reporter\n```\n\n## Usage\nRun mocha with `mocha-junit-reporter`:\n\n```shell\n$ mocha test --reporter mocha-junit-reporter\n```\nThis will output a results file at `./test-results.xml`.\nYou may optionally declare an alternate location for results XML file by setting\nthe environment variable `MOCHA_FILE` or specifying `mochaFile` in `reporterOptions`:\n\n```shell\n$ MOCHA_FILE=./path_to_your/file.xml mocha test --reporter mocha-junit-reporter\n```\nor\n```shell\n$ mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=./path_to_your/file.xml\n```\nor\n```javascript\nvar mocha = new Mocha({\n    reporter: 'mocha-junit-reporter',\n    reporterOptions: {\n        mochaFile: './path_to_your/file.xml'\n    }\n});\n```\n\n### Append properties to testsuite\n\nYou can also add properties to the report under `testsuite`. This is useful if you want your CI environment to add extra build props to the report for analytics purposes\n\n```xml\n<testsuites>\n  <testsuite>\n    <properties>\n      <property name=\"BUILD_ID\" value=\"4291\"/>\n    </properties>\n    <testcase/>\n    <testcase/>\n    <testcase/>\n  </testsuite>\n</testsuites>\n```\n\nTo do so pass them in via env variable:\n```shell\nPROPERTIES=BUILD_ID:4291 mocha test --reporter mocha-junit-reporter\n```\nor\n```javascript\nvar mocha = new Mocha({\n    reporter: 'mocha-junit-reporter',\n    reporterOptions: {\n        properties: {\n            BUILD_ID: 4291\n        }\n    }\n})\n```\n\n### Results Report\n\nResults XML filename can contain `[hash]`, e.g. `./path_to_your/test-results.[hash].xml`. `[hash]` is replaced by MD5 hash of test results XML. This enables support of parallel execution of multiple `mocha-junit-reporter`'s writing test results in separate files.\n\nIn order to display full suite title (including parents) just specify `testsuitesTitle` option\n```javascript\nvar mocha = new Mocha({\n    reporter: 'mocha-junit-reporter',\n    reporterOptions: {\n        testsuitesTitle: true,\n        suiteTitleSeparatedBy: '.' // suites separator, default is space (' '), or period ('.') in jenkins mode\n    }\n});\n```\n\nIf you want to **switch classname and name** of the generated testCase XML entries, you can use the `testCaseSwitchClassnameAndName` reporter option.\n\n```javascript\nvar mocha = new Mocha({\n    reporter: 'mocha-junit-reporter',\n    reporterOptions: {\n        testCaseSwitchClassnameAndName: true\n    }\n});\n```\n\nHere is an example of the XML output when using the `testCaseSwitchClassnameAndName` option:\n\n| value             | XML output                                                                              |\n| ----------------- | --------------------------------------------------------------------------------------- |\n| `true`            | `<testcase name=\"should behave like so\" classname=\"Super Suite should behave like so\">` |\n| `false` (default) | `<testcase name=\"Super Suite should behave like so\" classname=\"should behave like so\">` |\n\nYou can also configure the `testsuites.name` attribute by setting `reporterOptions.testsuitesTitle` and the root suite's `name` attribute by setting `reporterOptions.rootSuiteTitle`.\n\n### System out and system err\nThe JUnit format defines a pair of tags - `<system-out/>` and `<system-err/>` - for describing a test's generated output\nand error streams, respectively. It is possible to pass the test outputs/errors as an array of text lines:\n```js\nit ('should report output', function () {\n  this.test.consoleOutputs = [ 'line 1 of output', 'line 2 of output' ];\n});\nit ('should report error', function () {\n  this.test.consoleErrors = [ 'line 1 of errors', 'line 2 of errors' ];\n});\n```\n\nSince this module is only a reporter and not a self-contained test runner, it does not perform\noutput capture itself. Thus, the author of the tests is responsible for providing a mechanism\nvia which the outputs/errors array will be populated.\n\nIf capturing only console.log/console.error is an option, a simple (if a bit hack-ish) solution is to replace\nthe implementations of these functions globally, like so:\n```js\nvar util = require('util');\n\ndescribe('my console tests', function () {\n  var originalLogFunction = console.log;\n  var originalErrorFunction = console.error;\n  beforeEach(function _mockConsoleFunctions() {\n    var currentTest = this.currentTest;\n    console.log = function captureLog() {\n      var formattedMessage = util.format.apply(util, arguments);\n      currentTest.consoleOutputs = (currentTest.consoleOutputs || []).concat(formattedMessage);\n    };\n    console.error = function captureError() {\n      var formattedMessage = util.format.apply(util, arguments);\n      currentTest.consoleErrors = (currentTest.consoleErrors || []).concat(formattedMessage);\n    };\n  });\n  afterEach(function _restoreConsoleFunctions() {\n    console.log = originalLogFunction;\n    console.error = originalErrorFunction;\n  });\n  it('should output something to the console', function() {\n    // This should end up in <system-out>:\n    console.log('hello, %s', 'world');\n  });\n});\n```\n\nRemember to run with `--reporter-options outputs=true` if you want test outputs in XML.\n\n### Attachments\nenabling the `attachments` configuration option will allow for attaching files and screenshots in [JUnit Attachments Plugin](https://wiki.jenkins.io/display/JENKINS/JUnit+Attachments+Plugin) format.\n\nAttachment path can be injected into the test object\n```js\nit ('should include attachment', function () {\n  this.test.attachments = ['/absolut/path/to/file.png'];\n});\n```\n\nIf both attachments and outputs are enabled, and a test injects both consoleOutputs and attachments, then\nthe XML output will look like the following:\n```xml\n<system-out>output line 1\noutput line 2\n[[ATTACHMENT|path/to/file]]</system-out>\n```\n\n### Full configuration options\n\n| Parameter                      | Default                | Effect                                                                                                                  |\n| ------------------------------ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------- |\n| mochaFile                      | `test-results.xml`     | configures the file to write reports to                                                                                 |\n| includePending                 | `false`                | if set to a truthy value pending tests will be included in the report                                                   |\n| properties                     | `null`                 | a hash of additional properties to add to each test suite                                                               |\n| toConsole                      | `false`                | if set to a truthy value the produced XML will be logged to the console                                                 |\n| useFullSuiteTitle              | `false`                | if set to a truthy value nested suites' titles will show the suite lineage                                              |\n| suiteTitleSeparatedBy          | ` ` (space)            | the character to use to separate nested suite titles. (defaults to ' ', '.' if in jenkins mode)                         |\n| testCaseSwitchClassnameAndName | `false`                | set to a truthy value to switch name and classname values                                                               |\n| rootSuiteTitle                 | `Root Suite`           | the name for the root suite. (defaults to 'Root Suite')                                                                 |\n| testsuitesTitle                | `Mocha Tests`          | the name for the `testsuites` tag (defaults to 'Mocha Tests')                                                           |\n| outputs                        | `false`                | if set to truthy value will include console output and console error output                                             |\n| attachments                    | `false`                | if set to truthy value will attach files to report in `JUnit Attachments Plugin` format (after console outputs, if any) |\n| antMode                        | `false`                | set to truthy value to return xml compatible with [Ant JUnit schema][ant-schema]                                        |\n| antHostname                    | `process.env.HOSTNAME` | hostname to use when running in `antMode`  will default to environment `HOSTNAME`                                       |\n| jenkinsMode                    | `false`                | if set to truthy value will return xml that will display nice results in Jenkins                                        |\n\n[travis-badge]: https://travis-ci.org/michaelleeallen/mocha-junit-reporter.svg?branch=master\n[travis-build]: https://travis-ci.org/michaelleeallen/mocha-junit-reporter\n[npm-badge]: https://img.shields.io/npm/v/mocha-junit-reporter.svg?maxAge=2592000\n[npm-listing]: https://www.npmjs.com/package/mocha-junit-reporter\n[ant-schema]: http://windyroad.org/dl/Open%20Source/JUnit.xsd\n","readmeFilename":"README.md"}