{"record":{"id":"4c87ff45c00f0410","repo":"avajs/ava","slug":"expected-an-implementation-use-test-todo-for","errorCode":null,"errorMessage":"Expected an implementation. Use `test.todo()` for tests without an implementation.","messagePattern":"Expected an implementation\\. Use `test\\.todo\\(\\)` for tests without an implementation\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/runner.js","lineNumber":131,"sourceCode":"\t\t\t\t}\n\n\t\t\t\tif (!this.registerUniqueTitle(title.value)) {\n\t\t\t\t\tthrow new Error(`Duplicate test title: ${title.value}`);\n\t\t\t\t}\n\n\t\t\t\t// --match selects TODO tests.\n\t\t\t\tmetadata.selected &&= isTitleMatch(title.value, this.matchPatterns);\n\n\t\t\t\tthis.tasks.todo.push({title: title.value, metadata});\n\t\t\t\tthis.emit('stateChange', {\n\t\t\t\t\ttype: 'declared-test',\n\t\t\t\t\ttitle: title.value,\n\t\t\t\t\tknownFailing: false,\n\t\t\t\t\ttodo: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tif (typeof implementation !== 'function') {\n\t\t\t\t\tthrow new TypeError('Expected an implementation. Use `test.todo()` for tests without an implementation.');\n\t\t\t\t}\n\n\t\t\t\tif (title.isSet && !title.isValid) {\n\t\t\t\t\tthrow new TypeError('Test & hook titles must be strings');\n\t\t\t\t}\n\n\t\t\t\tlet fallbackTitle = title.value;\n\t\t\t\tif (title.isEmpty) {\n\t\t\t\t\tif (metadata.type === 'test') {\n\t\t\t\t\t\tthrow new TypeError('Tests must have a title');\n\t\t\t\t\t} else if (metadata.always) {\n\t\t\t\t\t\tfallbackTitle = `${metadata.type}.always hook`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfallbackTitle = `${metadata.type} hook`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (metadata.type === 'test' && !this.registerUniqueTitle(title.value)) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L113-L149","documentation":"AVA throws this TypeError when a non-todo test or hook is declared without a function implementation. The chain callback expects typeof implementation === 'function'; anything else (undefined, a string, an object) fails. AVA points you to test.todo() as the correct way to declare a placeholder test with no implementation.","triggerScenarios":"test('title') with no second/third argument; passing a non-function (e.g. an async arrow assigned later, an undefined import, a string) as the implementation: test('x', myImpl) where myImpl is undefined due to a bad import or circular dependency.","commonSituations":"Forgot the callback entirely when scaffolding tests; a misnamed or wrongly-defaulted import resolves to undefined; an import cycle yields undefined at declaration time; converting test.skip back to test but leaving no callback.","solutions":["Pass an implementation function as the callback: test('title', async t => { ... })","If the test is intentionally unimplemented, use test.todo('title') instead","Check that the implementation variable/import actually resolves to a function (fix broken imports/circular deps)","If the test should not run yet, use test.skip('title', t => { ... }) which still requires a function"],"exampleFix":"// before\ntest('parses config');\n\n// after\ntest('parses config', t => {\n\tt.deepEqual(parseConfig('a=1'), {a: 1});\n});\n// or, if unimplemented:\ntest.todo('parses config');","handlingStrategy":"type-guard","validationCode":"if (typeof implementation !== 'function') {\n\tthrow new TypeError('test() requires an implementation function; use test.todo() if unimplemented');\n}\ntest('title', implementation);","typeGuard":"function hasImplementation(args) {\n\treturn args.length >= 2 && typeof args[args.length - 1] === 'function';\n}","tryCatchPattern":"try {\n\ttest(title, impl);\n} catch (err) {\n\tif (err.message.includes('Expected an implementation')) {\n\t\ttest.todo(title); // degrade to a todo placeholder\n\t} else {\n\t\tthrow err;\n\t}\n}","preventionTips":["Always pass a callback to test(); use test.todo() for placeholders","Verify imports used as implementations actually resolve (watch for circular dependencies)","When converting test.skip() back, restore the full implementation","Use an editor snippet/template for test declarations so the callback is never omitted"],"tags":["ava","missing-implementation","typeerror","api-misuse"],"backgroundTag":"missing-callback-argument","analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}