From 733240d6be47a98bdb4a957111b1c72166f7df4f Mon Sep 17 00:00:00 2001 From: SamTheisens Date: Sat, 3 Oct 2020 13:20:46 +0700 Subject: [PATCH] Renames error reporting flag to `reportTestSuiteErrors` and explains in the README that file path will be used as suite name in these cases --- README.md | 2 +- __tests__/buildJsonResults.test.js | 6 +++--- constants/index.js | 4 ++-- utils/buildJsonResults.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 62c391c..08ae9ae 100644 --- a/README.md +++ b/README.md @@ -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 `` | `"false"` | N/A diff --git a/__tests__/buildJsonResults.test.js b/__tests__/buildJsonResults.test.js index fefd960..d510d3e 100644 --- a/__tests__/buildJsonResults.test.js +++ b/__tests__/buildJsonResults.test.js @@ -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; @@ -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]; @@ -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" })); diff --git a/constants/index.js b/constants/index.js index df2eed1..f28550e 100644 --- a/constants/index.js +++ b/constants/index.js @@ -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' }, @@ -30,7 +30,7 @@ module.exports = { addFileAttribute: 'false', includeConsoleOutput: 'false', includeShortConsoleOutput: 'false', - reportNoResultsAsError: 'false', + reportTestSuiteErrors: 'false', testSuitePropertiesFile: 'junitProperties.js' }, SUITENAME_VAR: 'suitename', diff --git a/utils/buildJsonResults.js b/utils/buildJsonResults.js index 221d412..8388a7d 100644 --- a/utils/buildJsonResults.js +++ b/utils/buildJsonResults.js @@ -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; }