{"record":{"id":"42370c467716884c","repo":"avajs/ava","slug":"the-instanceof-property-of-the-second-argument-t","errorCode":null,"errorMessage":"The `instanceOf` property of the second argument to `${assertion}` must be a function","messagePattern":"The `instanceOf` property of the second argument to `(.+?)` must be a function","errorType":"validation","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"lib/assert.js","lineNumber":99,"sourceCode":"\t\t\t});\n\t\t}\n\n\t\texpectations = {};\n\t} else if (\n\t\ttypeof expectations === 'function'\n\t\t|| typeof expectations === 'string'\n\t\t|| expectations instanceof RegExp\n\t\t|| typeof expectations !== 'object'\n\t\t|| Array.isArray(expectations)\n\t\t|| Object.keys(expectations).length === 0\n\t) {\n\t\tthrow new AssertionError(`The second argument to \\`${assertion}\\` must be an expectation object, \\`null\\` or \\`undefined\\``, {\n\t\t\tassertion,\n\t\t\tformattedDetails: [formatWithLabel('Called with:', expectations)],\n\t\t});\n\t} else {\n\t\tif (Object.hasOwn(expectations, 'instanceOf') && typeof expectations.instanceOf !== 'function') {\n\t\t\tthrow new AssertionError(`The \\`instanceOf\\` property of the second argument to \\`${assertion}\\` must be a function`, {\n\t\t\t\tassertion,\n\t\t\t\tformattedDetails: [formatWithLabel('Called with:', expectations)],\n\t\t\t});\n\t\t}\n\n\t\tif (\n\t\t\tObject.hasOwn(expectations, 'message')\n\t\t\t&& typeof expectations.message !== 'string'\n\t\t\t&& !(expectations.message instanceof RegExp)\n\t\t\t&& !(typeof expectations.message === 'function')\n\t\t) {\n\t\t\tthrow new AssertionError(`The \\`message\\` property of the second argument to \\`${assertion}\\` must be a string, regular expression or a function`, {\n\t\t\t\tassertion,\n\t\t\t\tformattedDetails: [formatWithLabel('Called with:', expectations)],\n\t\t\t});\n\t\t}\n\n\t\tif (Object.hasOwn(expectations, 'name') && typeof expectations.name !== 'string') {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/assert.js#L81-L117","documentation":"validateExpectations guard: the expectations object contained an instanceOf key whose value is not a constructor function (e.g. a string class name or an instance). The input at fault is expectations.instanceOf.","triggerScenarios":"Thrown at lib/assert.js:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass the constructor itself: {instanceOf: TypeError}, not 'TypeError'","Import the error class you expect and reference it directly","Remove instanceOf if you meant to match with message or name"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}