jest-junit-xray v1.0.0
jest-junit-xray
A Jest reporter that creates junit xml files which are compatible with XRay.
Note: as of jest-junit 11.0.0 NodeJS >= 10.12.0 is required.
Installation
npm install jest-junit-xray
Usage
In your jest config add the following entry:
{
"reporters": [ "default", "jest-junit-xray" ]
}
Then simply run:
jest
For your Continuous Integration you can simply do:
jest --ci --reporters=default --reporters=jest-junit-xray
Configuration
jest-junit
offers several configurations based on environment variables or a jest-junit
key defined in package.json
or a reporter option. Please refer to the Readme.
This package extends the jest-junit
with one option:
Environment Variable Name | Reporter Config Name | Description | Default | Possible Injection Values |
---|---|---|---|---|
JEST_REQUIREMENTS_SEPARATOR | requirementsSeparator | Seperator for the requirements attribute for XRay report | -> | N/A |
You can configure these options via the command line as seen below:
JEST_REQUIREMENTS_SEPARATOR="$$$" jest
Or you can also define a jest-junit-xray
key in your package.json
. All are string values.
{
...
"jest-junit": {
"suiteName": "jest tests",
"outputDirectory": ".",
"outputName": "junit.xml",
"uniqueOutputName": "false",
"classNameTemplate": "{classname}-{title}",
"titleTemplate": "{classname}-{title}",
"ancestorSeparator": " › ",
"usePathForSuiteName": "true",
"requirementsSeparator": "$$$"
}
}
Or you can define your options in your reporter configuration.
// jest.config.js
{
reporters: [
"default",
[ "jest-junit-xray", { suiteName: "jest tests" } ]
]
}
Example
Below is one example how to configure it
block description and jest-juni-xray
options to create a XRay compatible .xml
.
describe('addition', () => {
it('REQUIREMENTID -> should add up', () => {
expect(1 + 2).toBe(3);
});
});
This should create this line in the report:
<testcase classname="addition" name="should add up" requirement="REQUIREMENTID" time="2.355">
</testcase>
2 years ago