0.0.2 • Published 5 years ago

cypress-junit v0.0.2

Weekly downloads
85
License
MIT
Repository
github
Last release
5 years ago

JUnit Reporter for Cypress

Produces JUnit-style XML test results.

Installation

$ npm install cypress-junit --save-dev

or as a global module

$ npm install -g cypress-junit

Usage

// cypress.json
{
  "reporter": "cypress-junit",
  "reporterOptions": {
    "mochaFile": "./path_to_your/[hash].xml",   
    "toConsole": true,
    "outputs": true
  }
}

Results Report

System out and system err

The JUnit format defines a pair of tags - <system-out/> and <system-err/> - for describing a test's generated output and error streams, respectively. It is possible to pass the test outputs/errors as an array of text lines:

it ('should report output', function () {
  this.test.timings.consoleOutputs = [ 'line 1 of output', 'line 2 of output' ];
});
it ('should report error', function () {
  this.test.timings.consoleErrors = [ 'line 1 of errors', 'line 2 of errors' ];
});

Attachments

enabling the attachments configuration option will allow for attaching files and screenshots in JUnit Attachments Plugin format.

Attachment path can be injected into the test object

it ('should include attachment', function () {
  this.test.timings.attachments = ['/absolut/path/to/file.png'];
});

If both attachments and outputs are enabled, and a test injects both consoleOutputs and attachments, then the XML output will look like the following:

<system-out>output line 1
output line 2
[[ATTACHMENT|path/to/file]]</system-out>

Full configuration options

ParameterEffect
mochaFileconfigures the file to write reports to
includePendingif set to a truthy value pending tests will be included in the report
propertiesa hash of additional properties to add to each test suite
toConsoleif set to a truthy value the produced XML will be logged to the console
useFullSuiteTitleif set to a truthy value nested suites' titles will show the suite lineage
suiteTitleSeparedBythe character to use to separate nested suite titles. (defaults to ' ')
testCaseSwitchClassnameAndNameset to a truthy value to switch name and classname values
rootSuiteTitlethe name for the root suite. (defaults to 'Root Suite')
testsuitesTitlethe name for the testsuites tag (defaults to 'Mocha Tests')
outputsif set to truthy value will include console output and console error output
attachmentsif set to truthy value will attach files to report in JUnit Attachments Plugin format (after console outputs, if any)
antModeset to truthy value to return xml compatible with Ant JUnit schema
antHostnamehostname to use when running in antMode will default to environment HOSTNAME
jenkinsModeif set to truthy value will return xml that will display nice results in Jenkins

Fork

this GIT is forked from michaelleeallen/mocha-junit-reporter