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

jest-junit

Package Overview
Dependencies
Maintainers
2
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 11.1.0 to 12.0.0

2

constants/index.js

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

JEST_JUNIT_INCLUDE_SHORT_CONSOLE_OUTPUT: 'includeShortConsoleOutput',
JEST_JUNIT_REPORT_TEST_SUITE_ERRORS: 'reportTestSuiteErrors',
JEST_USE_PATH_FOR_SUITE_NAME: 'usePathForSuiteName',

@@ -33,2 +34,3 @@ JEST_JUNIT_TEST_SUITE_PROPERTIES_JSON_FILE: 'testSuitePropertiesFile'

includeShortConsoleOutput: 'false',
reportTestSuiteErrors: 'false',
testSuitePropertiesFile: 'junitProperties.js'

@@ -35,0 +37,0 @@ },

2

package.json
{
"name": "jest-junit",
"version": "11.1.0",
"version": "12.0.0",
"description": "A jest reporter that generates junit xml files",

@@ -5,0 +5,0 @@ "main": "index.js",

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

| `JEST_JUNIT_INCLUDE_SHORT_CONSOLE_OUTPUT` | `includeShortConsoleOutput` | Adds short console output (only message value) to any testSuite that generates stdout during a test run. | `false` | N/A
| `JEST_JUNIT_REPORT_TEST_SUITE_ERRORS` | `reportTestSuiteErrors` | Reports test suites that failed to execute altogether as `error`. _Note:_ since the suite name cannot be determined from files that fail to load, it will default to file path.| `false` | N/A
| `JEST_USE_PATH_FOR_SUITE_NAME` | `usePathForSuiteName` | **DEPRECATED. Use `suiteNameTemplate` instead.** Use file path as the `name` attribute of `<testsuite>` | `"false"` | N/A

@@ -72,0 +73,0 @@

@@ -37,2 +37,14 @@ 'use strict';

const addErrorTestResult = function (suite) {
suite.testResults.push({
"ancestorTitles": [],
"duration": 0,
"failureMessages": [
suite.failureMessage
],
"numPassingAsserts": 0,
"status": "error"
})
}
module.exports = function (report, appDirectory, options) {

@@ -43,2 +55,11 @@ // Check if there is a junitProperties.js (or whatever they called it)

// If the usePathForSuiteName option is true and the
// suiteNameTemplate value is set to the default, overrides
// the suiteNameTemplate.
if (options.usePathForSuiteName === 'true' &&
options.suiteNameTemplate === toTemplateTag(constants.TITLE_VAR)) {
options.suiteNameTemplate = toTemplateTag(constants.FILEPATH_VAR);
}
// Generate a single XML file for all jest tests

@@ -51,2 +72,3 @@ let jsonResults = {

'failures': 0,
'errors': 0,
// Overall execution time:

@@ -62,14 +84,16 @@ // Since tests are typically executed in parallel this time can be significantly smaller

report.testResults.forEach((suite) => {
// Skip empty test suites
if (suite.testResults.length <= 0) {
const noResults = suite.testResults.length === 0;
if (noResults && options.reportTestSuiteErrors === 'false') {
return;
}
// If the usePathForSuiteName option is true and the
// suiteNameTemplate value is set to the default, overrides
// the suiteNameTemplate.
if (options.usePathForSuiteName === 'true' &&
options.suiteNameTemplate === toTemplateTag(constants.TITLE_VAR)) {
const noResultOptions = noResults ? {
suiteNameTemplate: toTemplateTag(constants.FILEPATH_VAR),
titleTemplate: toTemplateTag(constants.FILEPATH_VAR),
classNameTemplate: `Test suite failed to run`
} : {};
options.suiteNameTemplate = toTemplateTag(constants.FILEPATH_VAR);
const suiteOptions = Object.assign({}, options, noResultOptions);
if (noResults) {
addErrorTestResult(suite);
}

@@ -94,7 +118,8 @@

const suiteErrors = noResults ? 1 : 0;
let testSuite = {
'testsuite': [{
_attr: {
name: replaceVars(options.suiteNameTemplate, suiteNameVariables),
errors: 0, // not supported
name: replaceVars(suiteOptions.suiteNameTemplate, suiteNameVariables),
errors: suiteErrors,
failures: suite.numFailingTests,

@@ -111,32 +136,5 @@ skipped: suite.numPendingTests,

jsonResults.testsuites[0]._attr.failures += suite.numFailingTests;
jsonResults.testsuites[0]._attr.errors += suiteErrors;
jsonResults.testsuites[0]._attr.tests += suiteNumTests;
// Write stdout console output if available
if (options.includeConsoleOutput === 'true' && suite.console && suite.console.length) {
// Stringify the entire console object
// Easier this way because formatting in a readable way is tough with XML
// And this can be parsed more easily
let testSuiteConsole = {
'system-out': {
_cdata: JSON.stringify(suite.console, null, 2)
}
};
testSuite.testsuite.push(testSuiteConsole);
}
// Write short stdout console output if available
if (options.includeShortConsoleOutput === 'true' && suite.console && suite.console.length) {
// Extract and then Stringify the console message value
// Easier this way because formatting in a readable way is tough with XML
// And this can be parsed more easily
let testSuiteConsole = {
'system-out': {
_cdata: JSON.stringify(suite.console.map(item => item.message), null, 2)
}
};
testSuite.testsuite.push(testSuiteConsole);
}
if (!ignoreSuitePropertiesCheck) {

@@ -168,3 +166,3 @@ let junitSuiteProperties = require(junitSuitePropertiesFilePath)(suite);

suite.testResults.forEach((tc) => {
const classname = tc.ancestorTitles.join(options.ancestorSeparator);
const classname = tc.ancestorTitles.join(suiteOptions.ancestorSeparator);
const testTitle = tc.title;

@@ -184,4 +182,4 @@

_attr: {
classname: replaceVars(options.classNameTemplate, testVariables),
name: replaceVars(options.titleTemplate, testVariables),
classname: replaceVars(suiteOptions.classNameTemplate, testVariables),
name: replaceVars(suiteOptions.titleTemplate, testVariables),
time: tc.duration / 1000

@@ -192,3 +190,3 @@ }

if (options.addFileAttribute === 'true') {
if (suiteOptions.addFileAttribute === 'true') {
testCase.testcase[0]._attr.file = filepath;

@@ -199,6 +197,7 @@ }

// Nested underneath <testcase> tag
if (tc.status === 'failed') {
if (tc.status === 'failed'|| tc.status === 'error') {
tc.failureMessages.forEach((failure) => {
const tagName = tc.status === 'failed' ? 'failure': 'error'
testCase.testcase.push({
'failure': stripAnsi(failure)
[tagName]: stripAnsi(failure)
});

@@ -219,2 +218,30 @@ })

// Write stdout console output if available
if (suiteOptions.includeConsoleOutput === 'true' && suite.console && suite.console.length) {
// Stringify the entire console object
// Easier this way because formatting in a readable way is tough with XML
// And this can be parsed more easily
let testSuiteConsole = {
'system-out': {
_cdata: JSON.stringify(suite.console, null, 2)
}
};
testSuite.testsuite.push(testSuiteConsole);
}
// Write short stdout console output if available
if (suiteOptions.includeShortConsoleOutput === 'true' && suite.console && suite.console.length) {
// Extract and then Stringify the console message value
// Easier this way because formatting in a readable way is tough with XML
// And this can be parsed more easily
let testSuiteConsole = {
'system-out': {
_cdata: JSON.stringify(suite.console.map(item => item.message), null, 2)
}
};
testSuite.testsuite.push(testSuiteConsole);
}
jsonResults.testsuites.push(testSuite);

@@ -221,0 +248,0 @@ });

@@ -24,4 +24,2 @@ 'use strict';

function getAppOptions(pathToResolve) {
const initialPath = pathToResolve;
let traversing = true;

@@ -28,0 +26,0 @@

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