{"record":{"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":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":406,"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":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-jasmine2/src/jasmine/Env.ts#L388-L424","documentation":"describe's second argument must be a function. If a non-undefined, non-function value is passed (a string, object, number, array), Env.describe throws a TypeError naming the offending value. This is a stricter check than the undefined guard and catches wrong-typed arguments.","triggerScenarios":"Calling `describe('x', 'not a function')` or `describe('x', { foo: 1 })` or passing a config object where the callback was expected. The guard at Env.ts:405 checks `typeof specDefinitions !== 'function'`.","commonSituations":"Calling describe with an options object instead of a callback; passing the result of an assignment expression that returned a non-function; a helper that returns the wrong type; copy-paste from a table-driven test where the table was passed as the second arg.","solutions":["Ensure the second argument is a function: `describe('x', () => {})`.","If you intended a factory/helper, call it so it returns a function, or wrap: `describe('x', () => myHelper())`.","Double-check the value of any variable passed — log it before the describe call."],"exampleFix":"// before\ndescribe('my suite', { timeout: 5000 });\n// after\ndescribe('my suite', () => {\n  beforeEach(() => {}, 5000);\n});","handlingStrategy":"type-guard","validationCode":"function safeDescribe(name: string, fn: unknown) {\n  if (typeof fn !== 'function') {\n    throw new TypeError(`describe('${name}') second argument must be a function, got ${typeof fn}`);\n  }\n  return describe(name, fn as () => void);\n}","typeGuard":"function isFunction(value: unknown): value is Function {\n  return typeof value === 'function';\n}","tryCatchPattern":null,"preventionTips":["Ensure the describe callback is a function literal or a verified function reference.","Avoid passing config objects or strings as the describe callback.","Use TypeScript with strict callback types for test helpers."],"tags":["describe","api-misuse","typeerror","jasmine","validation"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}