{"id":"9018ad59203c5793","repo":"jestjs/jest","slug":"missing-second-argument-it-must-be-a-callback-fun-9018ad","errorCode":null,"errorMessage":"Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.","messagePattern":"Missing second argument\\. It must be a callback function\\. Perhaps you want to use `test\\.todo` for a test placeholder\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":555,"sourceCode":"        return spec;\n\n        function specResultCallback(result: SpecResult) {\n          clearResourcesForRunnable(spec.id);\n          currentSpec = null;\n          reporter.specDone(result);\n        }\n\n        function specStarted(spec: Spec) {\n          currentSpec = spec;\n          defaultResourcesForRunnable(spec.id, suite.id);\n          reporter.specStarted(spec.result);\n        }\n      };\n\n      this.it = function (description, fn, timeout) {\n        description = convertDescriptorToString(description);\n        if (fn === undefined) {\n          throw new Error(\n            'Missing second argument. It must be a callback function. Perhaps you want to use `test.todo` for a test placeholder.',\n          );\n        }\n        if (typeof fn !== 'function') {\n          throw new TypeError(\n            `Invalid second argument, ${fn}. It must be a callback function.`,\n          );\n        }\n        const spec = specFactory(\n          description,\n          fn,\n          currentDeclarationSuite,\n          timeout,\n        );\n        if (currentDeclarationSuite.markedPending) {\n          spec.pend();\n        }\n","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/Env.ts#L537-L573","documentation":"it()/test() requires a callback as the second argument. Env.ts:554-558 throws when fn is undefined, with a hint pointing to test.todo for placeholder tests. This distinguishes 'I forgot the body' from 'I want a placeholder' and nudges toward the right API.","triggerScenarios":"Calling `it('does a thing')` with no callback, or `it('does a thing', undefined)`. The check at Env.ts:554 (`fn === undefined`) throws at line 555.","commonSituations":"Writing a test title as a TODO before implementing the body; refactor that deleted the function but left the title; copy-paste missing the arrow function.","solutions":["If you want a placeholder, use test.todo('does a thing') instead of it('does a thing').","Otherwise, add the callback: it('does a thing', () => { ... }).","Delete the line if it is leftover scaffolding."],"exampleFix":"// before\nit('calculates tax');\n\n// after — intended placeholder\nit.todo('calculates tax');\n// or implemented\nit('calculates tax', () => { expect(calc(10)).toBe(1); });","handlingStrategy":"validation","validationCode":"function assertItHasBody(fn: unknown) {\n  if (fn === undefined) throw new Error('it needs a callback; use it.todo for placeholders');\n}","typeGuard":"function isItCall(args: [unknown, unknown]): boolean { return args.length >= 2; }","tryCatchPattern":null,"preventionTips":["Use it.todo('title') for placeholders rather than it('title').","Lint for it/test calls missing a callback."],"tags":["jasmine2","it","test","api-misuse","todo","test-structure"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}