{"record":{"id":"73306fd1e60bb1a8","repo":"jestjs/jest","slug":"the-option-summarythreshold-should-be-a-number","errorCode":null,"errorMessage":"The option summaryThreshold should be a number","messagePattern":"The option summaryThreshold should be a number","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-reporters/src/SummaryReporter.ts","lineNumber":78,"sourceCode":"  static readonly filename = __filename;\n\n  constructor(\n    globalConfig: Config.GlobalConfig,\n    options?: SummaryReporterOptions,\n  ) {\n    super();\n    this._globalConfig = globalConfig;\n    this._estimatedTime = 0;\n    this._validateOptions(options);\n    this._summaryThreshold = options?.summaryThreshold ?? 20;\n  }\n\n  private _validateOptions(options?: SummaryReporterOptions) {\n    if (\n      options?.summaryThreshold &&\n      typeof options.summaryThreshold !== 'number'\n    ) {\n      throw new TypeError('The option summaryThreshold should be a number');\n    }\n  }\n\n  // If we write more than one character at a time it is possible that\n  // Node.js exits in the middle of printing the result. This was first observed\n  // in Node.js 0.10 and still persists in Node.js 6.7+.\n  // Let's print the test failure summary character by character which is safer\n  // when hundreds of tests are failing.\n  private _write(string: string) {\n    for (let i = 0; i < string.length; i++) {\n      process.stderr.write(string.charAt(i));\n    }\n  }\n\n  override onRunStart(\n    aggregatedResults: AggregatedResult,\n    options: ReporterOnStartOptions,\n  ): void {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-reporters/src/SummaryReporter.ts#L60-L96","documentation":"Thrown by SummaryReporter's _validateOptions (as a TypeError) when the summaryThreshold reporter option is present but not a number. summaryThreshold controls how many failing tests the summary section lists; it must be a numeric value (defaults to 20).","triggerScenarios":"Configuring SummaryReporter with ['default', ['<rootDir>/SummaryReporter', {summaryThreshold: '20'}]] or passing a string/boolean/object as summaryThreshold.","commonSituations":"Reading summaryThreshold from an env var (always a string) without converting; YAML/JSON config accidentally quoting the number; copy-paste from docs that used a string; typo producing an object.","solutions":["Pass a plain number for summaryThreshold (e.g., {summaryThreshold: 50}).","If the value comes from process.env, wrap with Number(...) or parseInt.","Omit the option to accept the default of 20."],"exampleFix":"// before\nreporters: [['<rootDir>/SummaryReporter', {summaryThreshold: process.env.SUMMARY_THRESHOLD}]]\n// after\nreporters: [['<rootDir>/SummaryReporter', {summaryThreshold: Number(process.env.SUMMARY_THRESHOLD) || 20}]]","handlingStrategy":"validation","validationCode":"const threshold = options?.summaryThreshold;\nif (threshold != null && typeof threshold !== 'number') {\n  throw new TypeError('summaryThreshold must be a number');\n}","typeGuard":"const isSummaryThreshold = (x: unknown): x is number =>\n  x == null || typeof x === 'number';","tryCatchPattern":null,"preventionTips":["Pass summaryThreshold as a numeric literal in config.","Convert env-sourced values with Number(...) before assignment.","Validate reporter options in a shared config loader."],"tags":["reporter","config","validation","summary"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}