jestjs/jest · error · Error

Sum(${computedTotal}) of passed (${passedTestSuites}) and fa

Error message

Sum(${computedTotal}) of passed (${passedTestSuites}) and failed (${failedTestSuites}) test suites is greater than the total number of test suites (${totalTestSuites}). Please report the bug at https://github.com/jestjs/jest/issues

What it means

Internal invariant in GitHubActionsReporter.isLastTestSuite: numPassedTestSuites + numFailedTestSuites must never exceed numTotalTestSuites. If it does, the aggregated results are inconsistent and Jest treats it as a framework bug, asking the user to file an issue.

Source

Thrown at packages/jest-reporters/src/GitHubActionsReporter.ts:170

        .replaceAll('\n', '%0A'),
    );

    this.log(
      `\n::${type} file=${file},line=${line},title=${title}::${message}`,
    );
  }

  private isLastTestSuite(results: AggregatedResult): boolean {
    const passedTestSuites = results.numPassedTestSuites;
    const failedTestSuites = results.numFailedTestSuites;
    const totalTestSuites = results.numTotalTestSuites;
    const computedTotal = passedTestSuites + failedTestSuites;
    if (computedTotal < totalTestSuites) {
      return false;
    } else if (computedTotal === totalTestSuites) {
      return true;
    } else {
      throw new Error(
        `Sum(${computedTotal}) of passed (${passedTestSuites}) and failed (${failedTestSuites}) test suites is greater than the total number of test suites (${totalTestSuites}). Please report the bug at https://github.com/jestjs/jest/issues`,
      );
    }
  }

  private printFullResult(context: TestContext, results: TestResult): void {
    const rootDir = context.config.rootDir;
    let testDir = results.testFilePath.replace(rootDir, '');
    testDir = testDir.slice(1);
    const resultTree = this.getResultTree(
      results.testResults,
      testDir,
      results.perfStats,
    );
    this.printResultTree(resultTree, context.config, results.console);
  }

  private arrayEqual(a1: Array<any>, a2: Array<any>): boolean {

View on GitHub (pinned to 8e6d128e4a)

Solutions

  1. Upgrade Jest to the latest patch/minor of your major and re-run.
  2. Audit any custom reporter or test-runner integration that touches results.numPassedTestSuites/numFailedTestSuites/numTotalTestSuites.
  3. Reproduce with --runInBand to rule out worker race conditions.
  4. If it persists, file the bug at https://github.com/jestjs/jest/issues with the counts and a minimal repro.
Defensive patterns

Strategy: try-catch

Try / catch

// In a custom reporter wrapping GitHubActionsReporter
try {
  // let the reporter run
} catch (err) {
  if (err instanceof Error && /Sum\(.*\) of passed/.test(err.message)) {
    // known inconsistent AggregatedResult — log and continue rather than crash CI
    console.error('Inconsistent test suite counts:', err.message);
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Reached only when AggregatedResult counts are mutually inconsistent — e.g., a custom reporter or testResults transformer mutated numPassedTestSuites/numFailedTestSuites/numTotalTestSuites independently, or a Jest internal double-counted suites.

Common situations: A third-party/custom reporter mutating the AggregatedResult object; a buggy jest-circus/jest-jasmine integration double-reporting; a known regression in a specific Jest version; concurrent workers producing miscounted results.

Related errors


AI-assisted analysis of jestjs/jest@8e6d128e4a (2026-08-10). Data as JSON: /api/errors/5a180972b89e61ca. Report an issue: GitHub.