{"record":{"id":"06ccadc0990e3fcc","repo":"avajs/ava","slug":"duplicate-test-title-title-value","errorCode":null,"errorMessage":"Duplicate test title: ${title.value}","messagePattern":"Duplicate test title: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/runner.js","lineNumber":116,"sourceCode":"\t\t\t}\n\n\t\t\tmetadata.taskIndex = this.nextTaskIndex++;\n\n\t\t\tconst {args, implementation, title} = parseTestArgs(testArgs);\n\n\t\t\tmetadata.selected &&= this.checkSelectedByLineNumbers?.() ?? true;\n\n\t\t\tif (metadata.todo) {\n\t\t\t\tif (implementation) {\n\t\t\t\t\tthrow new TypeError('`todo` tests are not allowed to have an implementation. Use `test.skip()` for tests with an implementation.');\n\t\t\t\t}\n\n\t\t\t\tif (!title.raw) { // Either undefined or a string.\n\t\t\t\t\tthrow new TypeError('`todo` tests require a title');\n\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) {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/avajs/ava/blob/bbfd946322fdeca2b547a691d947fb4e18c0c67f/lib/runner.js#L98-L134","documentation":"The AVA test runner throws this when two tests are declared with the exact same title. During test declaration (synchronously at file load) every test title is registered via registerUniqueTitle(); a second registration of an equal title returns false and the constructor throws. Unique titles are required so snapshots and --match patterns can unambiguously identify tests.","triggerScenarios":"Calling test('name', t => {}) twice with the same title string, or a test.todo('name') sharing a title with another test or todo, where both calls happen before the runner starts (synchronously in the test file).","commonSituations":"Copy-pasting a test block and forgetting to change the title; generating tests in a loop with a static or duplicated title string; renaming a test via parameterization that collapses to identical titles; merging branches where two developers added a test with the same name.","solutions":["Rename one of the duplicate tests so every test title in the file is unique","If tests should share a scenario, use test.each-style parameterization with distinct interpolated titles","If a copy-pasted test is unintended, delete the duplicate","If the title is built dynamically, log/print the generated titles to find the collision"],"exampleFix":"// before\ntest('fetches user', async t => { ... });\ntest('fetches user', async t => { ... });\n\n// after\ntest('fetches user by id', async t => { ... });\ntest('fetches user by email', async t => { ... });","handlingStrategy":"validation","validationCode":"function assertUniqueTitles(tests) {\n\tconst seen = new Set();\n\tfor (const {title} of tests) {\n\t\tif (seen.has(title)) throw new Error(`Duplicate test title: ${title}`);\n\t\tseen.add(title);\n\t}\n}\n// call it over your declared/generated test definitions before running","typeGuard":"function hasUniqueTitles(titles) {\n\treturn new Set(titles).size === titles.length;\n}","tryCatchPattern":"try {\n\trunner.declareTests(tests);\n} catch (err) {\n\tif (err.message.startsWith('Duplicate test title:')) {\n\t\tconsole.error(`Fix duplicate title: ${err.message}`);\n\t}\n\tthrow err;\n}","preventionTips":["Never copy-paste a test block without renaming its title","When generating tests in loops, interpolate the loop variable into the title","Add a CI lint rule or helper that asserts unique titles across generated tests","Keep todo titles unique relative to regular test titles too"],"tags":["ava","duplicate-title","test-runner","api-misuse"],"backgroundTag":"duplicate-test-title","analyzedSha":"bbfd946322fdeca2b547a691d947fb4e18c0c67f","analyzedAt":"2026-09-02T01:24:43.834Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}