{"id":"bea3e706b1e1bba5","repo":"jestjs/jest","slug":"todo-must-be-called-with-only-a-description-bea3e7","errorCode":null,"errorMessage":"Todo must be called with only a description.","messagePattern":"Todo must be called with only a description\\.","errorType":"exception","errorClass":"ErrorWithStack","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":594,"sourceCode":"        if (currentSpec !== null) {\n          throw new Error(\n            `Tests cannot be nested. Test \"${spec.description}\" cannot run because it is nested within \"${currentSpec.description}\".`,\n          );\n        }\n        currentDeclarationSuite.addChild(spec);\n        return spec;\n      };\n\n      this.xit = function (...args) {\n        const spec = this.it.apply(this, args);\n        spec.pend('Temporarily disabled with xit');\n        return spec;\n      };\n\n      this.todo = function () {\n        const description = arguments[0];\n        if (arguments.length !== 1 || typeof description !== 'string') {\n          throw new ErrorWithStack(\n            'Todo must be called with only a description.',\n            this.todo,\n          );\n        }\n\n        const spec = specFactory(\n          description,\n          // eslint-disable-next-line @typescript-eslint/no-empty-function\n          () => {},\n          currentDeclarationSuite,\n        );\n        if (currentDeclarationSuite.markedPending) {\n          spec.pend();\n        } else {\n          spec.todo();\n        }\n        currentDeclarationSuite.addChild(spec);\n        return spec;","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/Env.ts#L576-L612","documentation":"todo() creates a test placeholder and must be called with exactly one string argument — the description. Env.ts:591-598 throws (via ErrorWithStack, preserving a callsite) when the argument count is not 1 or the description is not a string, because a todo carries no body and any extra/missing data is a misuse.","triggerScenarios":"Calling `it.todo()` (no arg), `it.todo('a', fn)` (extra arg), or `it.todo(42)` (non-string). The check at Env.ts:593 (`arguments.length !== 1 || typeof description !== 'string'`) fires ErrorWithStack at line 594.","commonSituations":"Writing `it.todo('name', () => {...})` thinking todo takes a body; passing a template literal that evaluates to undefined; chaining todo like a normal it with options.","solutions":["Call todo with exactly one string: it.todo('description').","If you actually want a body, use it('description', () => {...}) and later mark it skip, or use it.skip.","If you have a parameterized placeholder, create one todo per row."],"exampleFix":"// before — todo with a body (misuse)\nit.todo('not yet done', () => { /* ... */ });\n\n// after — pure placeholder\nit.todo('not yet done');","handlingStrategy":"type-guard","validationCode":"function assertTodoArgs(args: [unknown]) {\n  if (args.length !== 1 || typeof args[0] !== 'string') {\n    throw new Error('it.todo takes exactly one string description');\n  }\n}","typeGuard":"function isTodoArg(args: [unknown]): args is [string] {\n  return args.length === 1 && typeof args[0] === 'string';\n}","tryCatchPattern":null,"preventionTips":["Remember it.todo takes ONLY a title — no callback, no options.","Use it('title', fn) (or it.skip) when you need a body."],"tags":["jasmine2","todo","it","api-misuse","test-structure"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}