mochajs/mocha · error · Error
invalid or unsupported TAP version: ${JSON.stringify(tapVers
Error message
invalid or unsupported TAP version: ${JSON.stringify(tapVersion)} What it means
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.
Source
Thrown at lib/reporters/tap.js:118
}
/**
* Returns a `tapVersion`-appropriate TAP producer instance, if possible.
*
* @private
* @param {string} tapVersion - Version of TAP specification to produce.
* @returns {TAPProducer} specification-appropriate instance
* @throws {Error} if specification version has no associated producer.
*/
function createProducer(tapVersion) {
var producers = {
12: new TAP12Producer(),
13: new TAP13Producer(),
};
var producer = producers[tapVersion];
if (!producer) {
throw new Error(
"invalid or unsupported TAP version: " + JSON.stringify(tapVersion),
);
}
return producer;
}
/**
* @summary
* Constructs a new TAPProducer.
*
* @description
* <em>Only</em> to be used as an abstract base class.
*
* @private
* @constructor
*/
class TAPProducer {View on GitHub (pinned to 6bcbee4fd9)
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.
Example fix
// before (e.g. .mocharc.json)
{ "tapVersion": "13" }
// after
{ "tapVersion": 13 } Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_TAP_VERSIONS = [12, 13];
if (tapVersion !== undefined && !SUPPORTED_TAP_VERSIONS.includes(Number(tapVersion))) {
throw new Error(`tapVersion must be 12 or 13, got: ${JSON.stringify(tapVersion)}`);
} Type guard
const isSupportedTapVersion = (v) => v === 12 || v === 13;
Try / catch
try {
const reporter = new TapReporter(runner, { tapVersion });
} catch (err) {
if (err.message.startsWith('invalid or unsupported TAP version')) {
console.error('Use tapVersion: 13 (or 12); omit it for defaults.');
}
throw err;
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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`.
Related errors
AI-assisted analysis of mochajs/mocha@6bcbee4fd9 (2026-09-01).
Data as JSON: /api/errors/3e070f8b9d29710d.
Report an issue: GitHub.