Socket
Socket
Sign inDemoInstall

jest-junit

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-junit - npm Package Compare versions

Comparing version 10.0.0 to 11.0.0

4

constants/index.js

@@ -17,2 +17,3 @@ 'use strict';

JEST_USE_PATH_FOR_SUITE_NAME: 'usePathForSuiteName',
JEST_JUNIT_TEST_SUITE_PROPERTIES_JSON_FILE: 'testSuitePropertiesFile'
},

@@ -31,3 +32,4 @@ DEFAULT_OPTIONS: {

includeConsoleOutput: 'false',
includeShortConsoleOutput: 'false'
includeShortConsoleOutput: 'false',
testSuitePropertiesFile: 'junitProperties.js'
},

@@ -34,0 +36,0 @@ CLASSNAME_VAR: 'classname',

{
"name": "jest-junit",
"version": "10.0.0",
"version": "11.0.0",
"description": "A jest reporter that generates junit xml files",

@@ -10,3 +10,3 @@ "main": "index.js",

"engines": {
"node": ">=8.0.0"
"node": ">=10.12.0"
},

@@ -25,3 +25,3 @@ "files": [

"jest-validate": "^24.9.0",
"mkdirp": "^0.5.1",
"mkdirp": "^1.0.4",
"strip-ansi": "^5.2.0",

@@ -28,0 +28,0 @@ "uuid": "^3.3.3",

@@ -6,2 +6,4 @@ [![Build Status](https://travis-ci.org/jest-community/jest-junit.svg?branch=master)](https://travis-ci.org/jest-community/jest-junit)

Note: as of jest-junit 11.0.0 NodeJS >= 10.12.0 is required.
## Installation

@@ -12,5 +14,2 @@ ```shell

## Important Notice
Soon jest-junit will no longer function as a testResultProcessor. It will only work as a jest reporter. See the docs just below this for how to transition your project.
## Usage

@@ -225,1 +224,26 @@ In your jest config add the following entry:

```
#### Adding custom testsuite properties
New feature as of jest-junit 11.0.0!
Create a file in your project root directory named junitProperties.js:
```js
module.exports = () => {
return {
key: "value"
}
});
```
Will render
```xml
<testsuites name="jest tests">
<testsuite name="addition" tests="1" errors="0" failures="0" skipped="0" timestamp="2017-07-13T09:42:28" time="0.161">
<properties>
<property name="key" value="value" />
</properties>
<testcase classname="addition positive numbers should add up" name="addition positive numbers should add up" time="0.004">
</testcase>
</testsuite>
</testsuites>
```

@@ -6,4 +6,4 @@ 'use strict';

const path = require('path');
const fs = require('fs');
// Wrap the varName with template tags

@@ -39,2 +39,6 @@ const toTemplateTag = function (varName) {

module.exports = function (report, appDirectory, options) {
// Check if there is a junitProperties.js (or whatever they called it)
const junitSuitePropertiesFilePath = path.join(process.cwd(), options.testSuitePropertiesFile);
let ignoreSuitePropertiesCheck = !fs.existsSync(junitSuitePropertiesFilePath);
// Generate a single XML file for all jest tests

@@ -119,3 +123,3 @@ let jsonResults = {

}
// Write short stdout console output if available

@@ -135,2 +139,26 @@ if (options.includeShortConsoleOutput === 'true' && suite.console && suite.console.length) {

if (!ignoreSuitePropertiesCheck) {
let junitSuiteProperties = require(junitSuitePropertiesFilePath)(suite);
// Add any test suite properties
let testSuitePropertyMain = {
'properties': []
};
Object.keys(junitSuiteProperties).forEach((p) => {
let testSuiteProperty = {
'property': {
_attr: {
name: p,
value: replaceVars(junitSuiteProperties[p], suiteNameVariables)
}
}
};
testSuitePropertyMain.properties.push(testSuiteProperty);
});
testSuite.testsuite.push(testSuitePropertyMain);
}
// Iterate through test cases

@@ -137,0 +165,0 @@ suite.testResults.forEach((tc) => {

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