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

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 4.0.0 to 5.0.0

54

index.js

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

const path = require('path');
const jestValidate = require('jest-validate');

@@ -12,2 +13,19 @@ const buildJsonResults = require('./utils/buildJsonResults');

const processor = (report, reporterOptions = {}) => {
// If jest-junit is used as a reporter allow for reporter options
// to be used. Env and package.json will override.
const options = getOptions.options(reporterOptions);
const jsonResults = buildJsonResults(report, fs.realpathSync(process.cwd()), options);
// Ensure output path exists
mkdirp.sync(path.dirname(options.output));
// Write data to file
fs.writeFileSync(options.output, xml(jsonResults, { indent: ' '}));
// Jest 18 compatibility
return report;
};
/*

@@ -24,14 +42,30 @@ At the end of ALL of the test suites this method is called

*/
module.exports = (report) => {
const options = getOptions.options();
const jsonResults = buildJsonResults(report, fs.realpathSync(process.cwd()), options);
// Ensure output path exists
mkdirp.sync(path.dirname(options.output));
// This is an old school "class" in order
// for the constructor to be invoked statically and via "new"
// so we can support both testResultsProcessor and reporters
// TODO: refactor to es6 class after testResultsProcessor support is removed
function JestJUnit (globalConfig, options) {
// See if constructor was invoked statically
// which indicates jest-junit was invoked as a testResultsProcessor
// and show deprecation warning
// Write data to file
fs.writeFileSync(options.output, xml(jsonResults, { indent: ' '}));
if (globalConfig.hasOwnProperty('testResults')) {
const newConfig = JSON.stringify({
reporters: ['jest-junit']
}, null, 2);
// Jest 18 compatibility
return report;
};
jestValidate.logValidationWarning('testResultsProcessor support is deprecated. Please use jest reporter. See https://github.com/jest-community/jest-junit#usage', newConfig);
return processor(globalConfig);
}
this._globalConfig = globalConfig;
this._options = options;
this.onRunComplete = (contexts, results) => {
processor(results, this._options);
};
}
module.exports = JestJUnit;

9

package.json
{
"name": "jest-junit",
"version": "4.0.0",
"description": "A jest result processor that generates junit xml files",
"version": "5.0.0",
"description": "A jest reporter that generates junit xml files",
"main": "index.js",
"repository": "https://github.com/palmerj3/jest-junit",
"repository": "https://github.com/jest-community/jest-junit",
"author": "Jason Palmer",

@@ -20,5 +20,6 @@ "license": "Apache-2.0",

"pretest:ci": "npm install jest@$JEST_VERSION --no-save",
"test:ci": "jest --ci && jest --ci --config ./integration-tests/jest.config.js"
"test:ci": "jest --ci"
},
"dependencies": {
"jest-validate": "^23.0.1",
"mkdirp": "^0.5.1",

@@ -25,0 +26,0 @@ "strip-ansi": "^4.0.0",

@@ -1,2 +0,2 @@

[![Build Status](https://travis-ci.org/palmerj3/jest-junit.svg?branch=master)](https://travis-ci.org/palmerj3/jest-junit)
[![Build Status](https://travis-ci.org/jest-community/jest-junit.svg?branch=master)](https://travis-ci.org/jest-community/jest-junit)

@@ -11,2 +11,5 @@ # jest-junit

## Important Notice
In an upcoming major version 5.x 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

@@ -16,2 +19,16 @@ In your jest config add the following entry:

{
"reporters": [ "default", "jest-junit" ]
}
```
Then simply run:
```shell
jest
```
## Usage as testResultsProcessor
In your jest config add the following entry:
```JSON
{
"testResultsProcessor": "jest-junit"

@@ -34,3 +51,3 @@ }

`jest-junit` offers five configurations based on environment variables or a `jest-junit` key defined in `package.json`. All configuration values should be **strings**.
`jest-junit` offers seven configurations based on environment variables or a `jest-junit` key defined in `package.json` or a reporter option. All configuration values should be **strings**.

@@ -70,2 +87,14 @@ | Variable Name | Description | Default | Possible Injection Values

Or you can define your options in your reporter configuration.
```js
// jest.config.js
{
reporters: [
"default",
[ "jest-junit", { suiteName: "jest tests" } ]
]
}
```
### Configuration Precedence

@@ -72,0 +101,0 @@ If using the `usePathForSuiteName` and `suiteNameTemplate`, the `usePathForSuiteName` value will take precedence. ie: if `usePathForSuiteName=true` and `suiteNameTemplate="{filename}"`, the filepath will be used as the `name` attribute of the `<testsuite>` in the rendered `jest-junit.xml`).

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

module.exports = {
options: function () {
return Object.assign({}, constants.DEFAULT_OPTIONS, getAppOptions(process.cwd()), getEnvOptions());
options: (reporterOptions = {}) => {
return Object.assign({}, constants.DEFAULT_OPTIONS, reporterOptions, getAppOptions(process.cwd()), getEnvOptions());
},

@@ -52,0 +52,0 @@ getAppOptions: getAppOptions,

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