Skip to content

Error Codes

When Mocha itself throws exception, the associated Error will have a code property. Where applicable, consumers should check the code property instead of string-matching against the message property. The following table describes these error codes:

CodeDescription
ERR_MOCHA_FATALan unrecoverable error occurred
ERR_MOCHA_FORBIDDEN_EXCLUSIVITY.only() was used with --forbid-only
ERR_MOCHA_INSTANCE_ALREADY_DISPOSEDrun() was called on a Mocha instance that has already been disposed
ERR_MOCHA_INSTANCE_ALREADY_RUNNINGrun() was called on a Mocha instance that is already running
ERR_MOCHA_INVALID_ARG_TYPEwrong type was passed for a given argument
ERR_MOCHA_INVALID_ARG_VALUEinvalid or unsupported value was passed for a given argument
ERR_MOCHA_INVALID_EXCEPTIONa falsy or otherwise underspecified exception was thrown
ERR_MOCHA_INVALID_INTERFACEinterface specified in options not found
ERR_MOCHA_INVALID_PLUGIN_DEFINITIONa plugin definition (e.g., mochaHooks) was invalid
ERR_MOCHA_INVALID_PLUGIN_IMPLEMENTATIONa user-supplied plugin implementation was invalid
ERR_MOCHA_INVALID_REPORTERreporter specified in options not found
ERR_MOCHA_MULTIPLE_DONEdone() was called multiple times in a test or hook
ERR_MOCHA_NO_FILES_MATCH_PATTERNtest file(s) could not be found
ERR_MOCHA_TIMEOUTa test or hook exceeded its allowed run time
ERR_MOCHA_UNPARSABLE_FILEa configuration or test file could not be parsed
ERR_MOCHA_UNSUPPORTEDrequested behavior, option, or parameter is unsupported