{"record":{"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":"validation","errorClass":"ErrorWithStack","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/Env.ts","lineNumber":602,"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":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-jasmine2/src/jasmine/Env.ts#L584-L620","documentation":"The `todo()` / `it.todo()` API creates a pending test placeholder with ONLY a description string — no callback. Env.todo enforces exactly one argument of type string at Env.ts:601. Any other shape (zero args, multiple args, a non-string, or passing a callback) throws an ErrorWithStack pointing at the todo call site.","triggerScenarios":"Calling `it.todo('x', () => {})` (callback not allowed), `it.todo()` (no description), `it.todo(123)` (non-string), or `it.todo('a', 'b')` (too many args). The guard at Env.ts:601 checks `arguments.length !== 1 || typeof description !== 'string'`.","commonSituations":"Confusing todo with a regular test (passing a body); passing a number or symbol as description; a wrapper that forwards extra arguments.","solutions":["Call todo with exactly one string: `it.todo('description')`.","If you need a body, use `it('description', () => {})` or `it.skip(...)` instead.","If generating descriptions, coerce to string: `it.todo(String(name))`."],"exampleFix":"// before\nit.todo('will do later', () => { /* ... */ });\n// after\nit.todo('will do later');\n// or, if you have a body to skip:\nit.skip('will do later', () => { /* ... */ });","handlingStrategy":"type-guard","validationCode":"function safeTodo(description: string) {\n  if (typeof description !== 'string') {\n    throw new TypeError(`todo() requires a single string description, got ${typeof description}`);\n  }\n  return it.todo(description);\n}","typeGuard":"function isTodoDescription(value: unknown): value is string {\n  return typeof value === 'string';\n}","tryCatchPattern":null,"preventionTips":["Call it.todo with exactly one string argument.","Do not pass a callback to todo — use it() or it.skip() for that.","Coerce generated descriptions to string if they come from data."],"tags":["todo","it","api-misuse","jasmine","validation"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}