Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-junit-reporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-junit-reporter

A JUnit reporter for mocha.

  • 1.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
52K
increased by18.72%
Maintainers
1
Weekly downloads
 
Created
Source

JUnit Reporter for Cypress

npm

Produces JUnit-style XML test results.

Installation

$ npm install cypress-junit-reporter --save-dev

or as a global module

$ npm install -g cypress-junit-reporter

Usage

Run mocha with cypress-junit-reporter:

$ mocha test --reporter cypress-junit-reporter

This will output a results file at ./test-results.xml. You may optionally declare an alternate location for results XML file by setting the environment variable MOCHA_FILE or specifying mochaFile in reporterOptions:

$ MOCHA_FILE=./path_to_your/file.xml mocha test --reporter cypress-junit-reporter

or

$ mocha test --reporter cypress-junit-reporter --reporter-options mochaFile=./path_to_your/file.xml

or

var mocha = new Mocha({
    reporter: 'cypress-junit-reporter',
    reporterOptions: {
        mochaFile: './path_to_your/file.xml'
    }
});

Append properties to testsuite

You 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

<testsuites>
  <testsuite>
    <properties>
      <property name="BUILD_ID" value="4291"/>
    </properties>
    <testcase/>
    <testcase/>
    <testcase/>
  </testsuite>
</testsuites>

To do so pass them in via env variable:

PROPERTIES=BUILD_ID:4291 mocha test --reporter cypress-junit-reporter

or

var mocha = new Mocha({
    reporter: 'cypress-junit-reporter',
    reporterOptions: {
        properties: {
            BUILD_ID: 4291
        }
    }
})

Results Report

Results 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 cypress-junit-reporter's writing test results in separate files.

In order to display full suite title (including parents) just specify testsuitesTitle option

var mocha = new Mocha({
    reporter: 'cypress-junit-reporter',
    reporterOptions: {
        testsuitesTitle: true,
        suiteTitleSeparatedBy: '.' // suites separator, default is space (' ')
    }
});

If you want to switch classname and name of the generated testCase XML entries, you can use the testCaseSwitchClassnameAndName reporter option.

var mocha = new Mocha({
    reporter: 'cypress-junit-reporter',
    reporterOptions: {
        testCaseSwitchClassnameAndName: true
    }
});

Here is an example of the XML output when using the testCaseSwitchClassnameAndName option:

valueXML output
true<testcase name="should behave like so" classname="Super Suite should behave like so">
false (default)<testcase name="Super Suite should behave like so" classname="should behave like so">

You can also configure the testsuites.name attribute by setting reporterOptions.testsuitesTitle and the root suite's name attribute by setting reporterOptions.rootSuiteTitle.

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')

Keywords

FAQs

Package last updated on 03 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc