{"record":{"id":"3e070f8b9d29710d","repo":"mochajs/mocha","slug":"invalid-or-unsupported-tap-version-json-stringi","errorCode":null,"errorMessage":"invalid or unsupported TAP version: ${JSON.stringify(tapVersion)}","messagePattern":"invalid or unsupported TAP version: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/reporters/tap.js","lineNumber":118,"sourceCode":"}\n\n/**\n * Returns a `tapVersion`-appropriate TAP producer instance, if possible.\n *\n * @private\n * @param {string} tapVersion - Version of TAP specification to produce.\n * @returns {TAPProducer} specification-appropriate instance\n * @throws {Error} if specification version has no associated producer.\n */\nfunction createProducer(tapVersion) {\n  var producers = {\n    12: new TAP12Producer(),\n    13: new TAP13Producer(),\n  };\n  var producer = producers[tapVersion];\n\n  if (!producer) {\n    throw new Error(\n      \"invalid or unsupported TAP version: \" + JSON.stringify(tapVersion),\n    );\n  }\n\n  return producer;\n}\n\n/**\n * @summary\n * Constructs a new TAPProducer.\n *\n * @description\n * <em>Only</em> to be used as an abstract base class.\n *\n * @private\n * @constructor\n */\nclass TAPProducer {","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/mochajs/mocha/blob/6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a/lib/reporters/tap.js#L100-L136","documentation":"The TAP reporter supports only TAP versions 12 and 13. `createProducer` looks up a producer in a map keyed by the numeric `tapVersion` option and throws when the value is anything else, guarding against emitting non-conformant TAP output.","triggerScenarios":"`new TapReporter(runner, {tapVersion: 11})`; `{tapVersion: '13'}` (string instead of number); `{tapVersion: 99}`; the option parsed from config as a string and therefore not matching numeric keys 12/13.","commonSituations":"Config files specifying `\"tapVersion\": \"13\"` (string) instead of `13` (number); copying an old `tapVersion: 0`/`11` snippet from pre-Mocha-6 docs; typos like `tapVersiom`.","solutions":["Set `tapVersion` to the number 13 (recommended) or 12: `{ tapVersion: 13 }`.","Ensure the value is a number, not a string — quote-less `13` in JSON/JS config.","Remove the `tapVersion` option entirely to use the default producer.","Check the Mocha version: TAP13 support exists in Mocha >= 6."],"exampleFix":"// before (e.g. .mocharc.json)\n{ \"tapVersion\": \"13\" }\n\n// after\n{ \"tapVersion\": 13 }","handlingStrategy":"validation","validationCode":"const SUPPORTED_TAP_VERSIONS = [12, 13];\nif (tapVersion !== undefined && !SUPPORTED_TAP_VERSIONS.includes(Number(tapVersion))) {\n  throw new Error(`tapVersion must be 12 or 13, got: ${JSON.stringify(tapVersion)}`);\n}","typeGuard":"const isSupportedTapVersion = (v) => v === 12 || v === 13;","tryCatchPattern":"try {\n  const reporter = new TapReporter(runner, { tapVersion });\n} catch (err) {\n  if (err.message.startsWith('invalid or unsupported TAP version')) {\n    console.error('Use tapVersion: 13 (or 12); omit it for defaults.');\n  }\n  throw err;\n}","preventionTips":["Coerce config strings to numbers at config-load time.","Omit tapVersion unless you specifically need TAP12/TAP13 semantics.","Validate .mocharc files (13 as a number, not \"13\" as a string).","Pin documented Mocha versions where TAP13 is supported."],"tags":["reporters","tap","option-validation"],"backgroundTag":"unsupported-option-value","analyzedSha":"6bcbee4fd9a95351cedf0fdcb14c7d696486bc5a","analyzedAt":"2026-09-01T03:41:47.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}