JSPM

  • Created
  • Published
  • Downloads 6416815
  • Score
    100M100P100Q219164F
  • License Apache 2.0

A jest result processor that generates junit xml files

Package Exports

  • jest-junit

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jest-junit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

jest-junit

A Jest reporter that creates compatible junit xml files

Installation

yarn add --dev jest-junit

Usage

In your jest config add the following entry:

{
  "testResultsProcessor": "./node_modules/jest-junit"
}

Then simply run:

jest

Configuration

jest-junit offers five configurations based on environment variables. All are string values.

JEST_SUITE_NAME: Default "jest tests"

JEST_JUNIT_OUTPUT: Default "./junit.xml"

JEST_JUNIT_CLASSNAME: Default "{classname}-{title}"

JEST_JUNIT_TITLE: Default "{classname}-{title}"

JEST_USE_PATH_FOR_SUITE_NAME: Default "false"

Example:

JEST_SUITE_NAME="Jest JUnit Unit Tests" JEST_JUNIT_OUTPUT="./artifacts/junit.xml" jest

You can also define a jest-junit key in your package.json. All are string values.

{
    ...
    "jest-junit": {
        "suiteName": "jest tests",
        "output": "./junit.xml",
        "classNameTemplate": "{classname}-{title}",
        "titleTemplate": "{classname}-{title}",
        "usePathForSuiteName": "true"
    }
}

Example output:

<testsuites name="Jest JUnit Unit Tests">
  <testsuite name="My first suite" tests="1" errors="0" failures="0" skipped="0" timestamp="2016-11-19T01:37:20" time="0.105">
    <testcase classname="My test case" name="My test case" time="6">
    </testcase>
  </testsuite>
</testsuites>

Changing the title and classname

JEST_JUNIT_CLASSNAME="{classname}" JEST_JUNIT_TITLE="{title}" jest
<testsuites name="jest tests">
  <testsuite name="foo" tests="1" errors="0" failures="0" skipped="0" timestamp="2017-02-19T22:36:15" time="0.232">
    <testcase classname="foo" name="bar" time="0.003">
    </testcase>
  </testsuite>
</testsuites>