Skip to content

Commit

Permalink
Renames error reporting flag to reportTestSuiteErrors
Browse files Browse the repository at this point in the history
and explains in the README that file path will be used as suite name in
these cases
  • Loading branch information
SamTheisens committed Oct 4, 2020
1 parent f4c9f26 commit 733240d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Reporter options should also be strings exception for suiteNameTemplate, classNa
| `JEST_JUNIT_ADD_FILE_ATTRIBUTE` | `addFileAttribute` | Add file attribute to the output. This config is primarily for Circle CI. This setting provides richer details but may break on other CI platforms. Must be a string. | `"false"` | N/A
| `JEST_JUNIT_INCLUDE_CONSOLE_OUTPUT` | `includeConsoleOutput` | Adds console output to any testSuite that generates stdout during a test run. | `false` | N/A
| `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_NO_RESULTS_AS_ERROR` | `reportNoResultsAsError` | Reports test files that failed to execute altogether due to a syntax or typescript compilation error, as a suite with a single test with `error` result. | `false` | N/A
| `JEST_JUNIT_REPORT_NO_RESULTS_AS_ERROR` | `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


Expand Down
6 changes: 3 additions & 3 deletions __tests__/buildJsonResults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('buildJsonResults', () => {

const jsonResults = buildJsonResults(failingTestsReport, '/path/to/test',
Object.assign({}, constants.DEFAULT_OPTIONS, {
reportNoResultsAsError: "true"
reportTestSuiteErrors: "true"
}));

const totals = jsonResults.testsuites[0]._attr;
Expand All @@ -164,7 +164,7 @@ describe('buildJsonResults', () => {

const jsonResults = buildJsonResults(failingTestsReport, '/path/to/test',
Object.assign({}, constants.DEFAULT_OPTIONS, {
reportNoResultsAsError: "true"
reportTestSuiteErrors: "true"
}));

const errorSuite = jsonResults.testsuites[1].testsuite[2];
Expand All @@ -178,7 +178,7 @@ describe('buildJsonResults', () => {

const jsonResults = buildJsonResults(failingTestsReport, '/path/to/test',
Object.assign({}, constants.DEFAULT_OPTIONS, {
reportNoResultsAsError: "true",
reportTestSuiteErrors: "true",
suiteNameTemplate: "{displayName}-foo",
titleTemplate: "{title}-bar"
}));
Expand Down
4 changes: 2 additions & 2 deletions constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
JEST_JUNIT_ADD_FILE_ATTRIBUTE: 'addFileAttribute',
JEST_JUNIT_INCLUDE_CONSOLE_OUTPUT: 'includeConsoleOutput',
JEST_JUNIT_INCLUDE_SHORT_CONSOLE_OUTPUT: 'includeShortConsoleOutput',
JEST_JUNIT_REPORT_NO_RESULTS_AS_ERROR: 'reportNoResultsAsError',
JEST_JUNIT_REPORT_NO_RESULTS_AS_ERROR: 'reportTestSuiteErrors',
JEST_USE_PATH_FOR_SUITE_NAME: 'usePathForSuiteName',
JEST_JUNIT_TEST_SUITE_PROPERTIES_JSON_FILE: 'testSuitePropertiesFile'
},
Expand All @@ -30,7 +30,7 @@ module.exports = {
addFileAttribute: 'false',
includeConsoleOutput: 'false',
includeShortConsoleOutput: 'false',
reportNoResultsAsError: 'false',
reportTestSuiteErrors: 'false',
testSuitePropertiesFile: 'junitProperties.js'
},
SUITENAME_VAR: 'suitename',
Expand Down
2 changes: 1 addition & 1 deletion utils/buildJsonResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = function (report, appDirectory, options) {
// Iterate through outer testResults (test suites)
report.testResults.forEach((suite) => {
const noResults = suite.testResults.length === 0;
if (noResults && options.reportNoResultsAsError === 'false') {
if (noResults && options.reportTestSuiteErrors === 'false') {
return;
}

Expand Down

0 comments on commit 733240d

Please sign in to comment.