From 11d975310b37a9b184ab05fe3857209fc44a8001 Mon Sep 17 00:00:00 2001 From: Mark Gallagher Date: Fri, 6 Oct 2023 23:19:15 +0100 Subject: [PATCH] Add todo count to total test count --- __tests__/buildJsonResults.test.js | 7 +++++++ utils/buildJsonResults.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/__tests__/buildJsonResults.test.js b/__tests__/buildJsonResults.test.js index b561e8e..79ff599 100644 --- a/__tests__/buildJsonResults.test.js +++ b/__tests__/buildJsonResults.test.js @@ -447,6 +447,13 @@ describe('buildJsonResults', () => { expect(jsonResults.testsuites[1].testsuite[0]._attr.skipped).toBe(1); }); + it('should include number of todo tests in testSuite total count', () => { + const noFailingTestsWithTodoReport = require('../__mocks__/no-failing-tests-with-todo.json'); + jsonResults = buildJsonResults(noFailingTestsWithTodoReport, '/', constants.DEFAULT_OPTIONS); + + expect(jsonResults.testsuites[1].testsuite[0]._attr.tests).toBe(2); + }); + it('should include a skipped tag when outputting todo tests', () => { const noFailingTestsWithTodoReport = require('../__mocks__/no-failing-tests-with-todo.json'); jsonResults = buildJsonResults(noFailingTestsWithTodoReport, '/', constants.DEFAULT_OPTIONS); diff --git a/utils/buildJsonResults.js b/utils/buildJsonResults.js index 5a247c7..6d40409 100644 --- a/utils/buildJsonResults.js +++ b/utils/buildJsonResults.js @@ -226,7 +226,7 @@ module.exports = function (report, appDirectory, options, rootDir = null) { suiteNameVariables[constants.DISPLAY_NAME_VAR] = displayName; // Add properties - const suiteNumTests = suite.numFailingTests + suite.numPassingTests + suite.numPendingTests; + const suiteNumTests = suite.numFailingTests + suite.numPassingTests + suite.numPendingTests + (suite.numTodoTests ? suite.numTodoTests: 0); const suiteExecutionTime = executionTime(suite.perfStats.start, suite.perfStats.end); const suiteErrors = noResults ? 1 : 0;