{"id":"1124ac182ec9ed3a","repo":"jestjs/jest","slug":"todo-must-be-called-with-only-a-description","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-circus/src/index.ts","lineNumber":174,"sourceCode":"      eachError?: Error,\n    ): void =>\n      _addTest(\n        testName,\n        mode,\n        concurrent,\n        fn,\n        failing,\n        timeout,\n        true,\n        eachError,\n      );\n    failing.each = bindEach(failing, false, true);\n    return failing;\n  };\n\n  test.todo = (testName: Circus.TestNameLike, ...rest: Array<any>): void => {\n    if (rest.length > 0 || typeof testName !== 'string') {\n      throw new ErrorWithStack(\n        'Todo must be called with only a description.',\n        test.todo,\n      );\n    }\n    // eslint-disable-next-line @typescript-eslint/no-empty-function\n    return _addTest(testName, 'todo', false, () => {}, test.todo);\n  };\n\n  const _addTest = (\n    testName: Circus.TestNameLike,\n    mode: Circus.TestMode,\n    concurrent: boolean,\n    fn: Circus.TestFn | undefined,\n    testFn: (\n      testName: Circus.TestNameLike,\n      fn: Circus.TestFn,\n      timeout?: number,\n    ) => void,","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-circus/src/index.ts#L156-L192","documentation":"test.todo() is a placeholder API that only records a test name to be implemented later; it must not receive a test function or any extra arguments (packages/jest-circus/src/index.ts:173). The implementation throws when `rest.length > 0` (more than one argument) OR when testName is not a string, because a todo test has no body to run.","triggerScenarios":"`test.todo('x', () => {})` (passing a function), `test.todo(name1, name2)` (passing multiple args), or `test.todo(myNameVariable)` where the variable is not a string (e.g. a number/symbol).","commonSituations":"Developers copy a `test(...)` call and only change `test` to `test.todo`, leaving the callback in place; or use test.todo where they actually want a skipped/pending real test.","solutions":["If you have an implementation, use `test('name', fn)` (or `test.skip` if you want to skip it).","If it is genuinely a placeholder, remove the extra arguments: `test.todo('name')` with a single string.","Ensure the first argument is a plain string literal or string variable."],"exampleFix":"// before\ntest.todo('calculates total', () => sum(1,2));\n\n// after\ntest('calculates total', () => sum(1,2));\n// or, as a genuine placeholder:\ntest.todo('calculates total');","handlingStrategy":"type-guard","validationCode":"// Wrap test.todo so misuse is caught at author time.\nfunction safeTodo(name: unknown, ...rest: unknown[]): void {\n  if (typeof name !== 'string' || rest.length > 0) {\n    throw new TypeError('test.todo expects exactly one string argument');\n  }\n  // test.todo(name)\n}","typeGuard":"function isValidTodoCall(name: unknown, rest: unknown[]): name is string {\n  return typeof name === 'string' && rest.length === 0;\n}","tryCatchPattern":null,"preventionTips":["Remember test.todo takes ONLY a name; use test() for real bodies.","Enable eslint-plugin-jest rules for consistent test API usage.","Treat a todo as a string-only placeholder."],"tags":["jest-circus","test-todo","test-definition"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}