jest-junit
Advanced tools
Comparing version 1.1.1 to 1.2.0
19
index.js
@@ -8,6 +8,18 @@ 'use strict'; | ||
// Look for these when replacing template vars | ||
const CLASSNAME_VAR = '{classname}'; | ||
const TITLE_VAR = '{title}'; | ||
const SUITE_NAME = process.env.JEST_SUITE_NAME || 'jest tests'; | ||
const OUTPUT_PATH = process.env.JEST_JUNIT_OUTPUT || | ||
path.join(process.cwd(), './junit.xml'); | ||
const CLASSNAME_TEMPLATE = process.env.JEST_JUNIT_CLASSNAME || '{classname} {title}'; | ||
const TITLE_TEMPLATE = process.env.JEST_JUNIT_TITLE || '{classname} {title}'; | ||
const replaceVars = function (str, classname, title) { | ||
return str | ||
.replace(CLASSNAME_VAR, classname) | ||
.replace(TITLE_VAR, title); | ||
}; | ||
/* | ||
@@ -60,7 +72,10 @@ At the end of ALL of the test suites this method is called | ||
suite.testResults.forEach((tc) => { | ||
const classname = tc.ancestorTitles.join(' '); | ||
const title = tc.title; | ||
let testCase = { | ||
'testcase': [{ | ||
_attr: { | ||
classname: tc.fullName, | ||
name: tc.fullName, | ||
classname: replaceVars(CLASSNAME_TEMPLATE, classname, title), | ||
name: replaceVars(TITLE_TEMPLATE, classname, title), | ||
time: tc.duration / 1000 | ||
@@ -67,0 +82,0 @@ } |
{ | ||
"name": "jest-junit", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "A jest result processor that generates junit xml files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ # jest-junit | ||
jest-junit offers two configurations based on environment variables. | ||
jest-junit offers four configurations based on environment variables. | ||
@@ -32,2 +32,6 @@ ```JEST_SUITE_NAME```: Default "jest tests" | ||
```JEST_JUNIT_CLASSNAME```: Default "{classname}-{title}" | ||
```JEST_JUNIT_TITLE```: Default "{classname}-{title}" | ||
Example: | ||
@@ -48,1 +52,16 @@ | ||
``` | ||
Changing the title and classname | ||
```shell | ||
JEST_JUNIT_CLASSNAME="{classname}" JEST_JUNIT_TITLE="{title}" jest | ||
``` | ||
```xml | ||
<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> | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16573
102
65
6