{"id":"d606d900a1c76804","repo":"jestjs/jest","slug":"missing-second-argument-it-must-be-a-callback-fun","errorCode":null,"errorMessage":"Missing second argument. It must be a callback function.","messagePattern":"Missing second argument\\. It must be a callback function\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":400,"sourceCode":"          id: getNextSuiteId(),\n          description,\n          parentSuite: currentDeclarationSuite,\n          throwOnExpectationFailure,\n          getTestPath() {\n            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        }","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/Env.ts#L382-L418","documentation":"describe() requires exactly two arguments: a description and a callback. Env.ts:399-403 throws when the second argument (specDefinitions) is undefined — i.e. describe was called with only a name. This catches a common typo before the suite is built.","triggerScenarios":"Calling `describe('name')` with no callback, or `describe('name', undefined)`. The check at Env.ts:399 (`specDefinitions === undefined`) triggers the throw at line 400.","commonSituations":"Incomplete test draft left in a file; refactor that removed the body but left the describe line; copy-paste missing the callback; accidental semicolon terminating the call.","solutions":["Provide the required callback: describe('name', () => { ... }).","If you intended a placeholder suite, use an empty callback describe('name', () => {}) or skip it.","Remove the incomplete describe line entirely if it is leftover scaffolding."],"exampleFix":"// before\ndescribe('calculator');\n\n// after\ndescribe('calculator', () => { it('adds', () => {}); });","handlingStrategy":"type-guard","validationCode":"function assertDescribeArgs(name: unknown, fn: unknown) {\n  if (fn === undefined) throw new Error('describe requires a callback as the 2nd argument');\n}","typeGuard":"function isDescribeArgs(args: [unknown, unknown]): args is [string, () => void] {\n  return args.length >= 2 && typeof args[1] === 'function';\n}","tryCatchPattern":null,"preventionTips":["Use TypeScript so describe signature mismatches surface at compile time.","Run a quick lint that flags describe calls with < 2 arguments."],"tags":["jasmine2","describe","api-misuse","test-structure"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}