{"record":{"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":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":401,"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":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-jasmine2/src/jasmine/Env.ts#L383-L419","documentation":"The `describe()` function requires exactly two arguments: a description and a callback. If the callback (specDefinitions) is undefined — i.e. describe was called with only one argument or the second argument was explicitly omitted — Env.describe throws this Error at Env.ts:401 before any suite is created.","triggerScenarios":"Calling `describe('my suite')` with no second argument, or `describe('my suite', undefined)`. The guard at Env.ts:400 checks `specDefinitions === undefined`.","commonSituations":"Incomplete/partially written test; copy-paste where the callback was dropped; a refactor that extracted the callback into a variable that is undefined at call time; a conditional that sometimes omits the callback.","solutions":["Add the missing callback: `describe('my suite', () => { ... })`.","If the suite body is not yet written, use an empty arrow function as a placeholder.","Check that any variable passed as the callback is defined before the describe call."],"exampleFix":"// before\ndescribe('my suite');\n// after\ndescribe('my suite', () => {\n  it('does something', () => {});\n});","handlingStrategy":"type-guard","validationCode":"// Wrap describe to enforce the callback at the call site.\nfunction safeDescribe(name: string, fn?: () => void) {\n  if (typeof fn !== 'function') {\n    throw new TypeError(`describe('${name}') requires a callback function.`);\n  }\n  return describe(name, fn);\n}","typeGuard":"function isDescribeCallback(value: unknown): value is () => void {\n  return typeof value === 'function';\n}","tryCatchPattern":null,"preventionTips":["Always provide a callback to describe, even an empty arrow function for stubs.","Use TypeScript types that require the second parameter.","Enable eslint-plugin-jest to catch malformed describe calls."],"tags":["describe","api-misuse","jasmine","validation","test-structure"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}