{"id":"3644f41f6ffd5f4e","repo":"jestjs/jest","slug":"invalid-second-argument-specdefinitions-it-mu","errorCode":null,"errorMessage":"Invalid second argument, ${specDefinitions}. It must be a callback function.","messagePattern":"Invalid second argument, (.+?)\\. It must be a callback function\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":405,"sourceCode":"            return j$.testPath;\n          },\n        });\n\n        return suite;\n      };\n\n      this.describe = function (\n        description: Circus.TestNameLike,\n        specDefinitions,\n      ) {\n        const suite = suiteFactory(description);\n        if (specDefinitions === undefined) {\n          throw new Error(\n            'Missing second argument. It must be a callback function.',\n          );\n        }\n        if (typeof specDefinitions !== 'function') {\n          throw new TypeError(\n            `Invalid second argument, ${specDefinitions}. It must be a callback function.`,\n          );\n        }\n        if (specDefinitions.length > 0) {\n          throw new Error('describe does not expect any arguments');\n        }\n        if (currentDeclarationSuite.markedPending) {\n          suite.pend();\n        }\n        if (currentDeclarationSuite.markedTodo) {\n          // @ts-expect-error TODO Possible error: Suite does not have todo method\n          suite.todo();\n        }\n        addSpecsToSuite(suite, specDefinitions);\n        return suite;\n      };\n\n      this.xdescribe = function (description, specDefinitions) {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/Env.ts#L387-L423","documentation":"describe()'s second argument must be a function. Env.ts:404-408 throws a TypeError (note: TypeError, not Error) when specDefinitions is defined but not a function — e.g. an object, array, string, or config object mistakenly passed as the body. The interpolated value in the message helps spot what was actually passed.","triggerScenarios":"Calling `describe('name', someObject)`, `describe('name', [...])`, or `describe('name', 'does things')`. The `typeof specDefinitions !== 'function'` check at Env.ts:404 fires the TypeError at line 405.","commonSituations":"Passing a configuration object instead of a function; destructuring mistake leaving the wrong binding as the second arg; tools that wrap describe and forward the wrong parameter.","solutions":["Pass a function as the second argument: describe('name', () => { ... }).","Inspect the interpolated value in the message to identify which non-function was passed and fix the binding.","If wrapping describe, ensure your wrapper forwards the callback in the correct position."],"exampleFix":"// before — object passed instead of callback\ndescribe('calculator', { tests: true });\n\n// after\ndescribe('calculator', () => { it('adds', () => {}); });","handlingStrategy":"type-guard","validationCode":"function assertDescribeFn(fn: unknown) {\n  if (typeof fn !== 'function') throw new TypeError('describe callback must be a function');\n}","typeGuard":"function isFn(v: unknown): v is Function { return typeof v === 'function'; }\nif (!isFn(specDefinitions)) throw new TypeError('describe callback missing');","tryCatchPattern":null,"preventionTips":["Type your test helpers so non-function describe bodies fail at compile time.","Lint for describe with a non-function second argument."],"tags":["jasmine2","describe","api-misuse","typeerror","test-structure"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}