{"record":{"id":"77816376d9815727","repo":"vitest-dev/vitest","slug":"the-prefix-tag-is-not-defined-in-the-confi","errorCode":null,"errorMessage":"The ${prefix} \"${tag}\" is not defined in the configuration. Available tags are:\n${availableTags.map(t => `- ${t.name}${t.description ? `: ${t.description}` : ''}`).join('\\n')}","messagePattern":"The (.+?) \"(.+?)\" is not defined in the configuration\\. Available tags are:\n(.+?)(.+?)` : ''\\}`\\)\\.join\\('\\\\n'\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/utils/tags.ts","lineNumber":41,"sourceCode":"\nexport function validateTags(config: SerializedConfig, tags: string[]): void {\n  if (!config.strictTags) {\n    return\n  }\n\n  const availableTags = new Set(config.tags.map(tag => tag.name))\n  for (const tag of tags) {\n    if (!availableTags.has(tag)) {\n      throw createNoTagsError(config.tags, tag)\n    }\n  }\n}\n\nexport function createNoTagsError(availableTags: TestTagDefinition[], tag: string, prefix = 'tag'): never {\n  if (!availableTags.length) {\n    throw new Error(`The Vitest config does't define any \"tags\", cannot apply \"${tag}\" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`)\n  }\n  throw new Error(`The ${prefix} \"${tag}\" is not defined in the configuration. Available tags are:\\n${availableTags\n    .map(t => `- ${t.name}${t.description ? `: ${t.description}` : ''}`)\n    .join('\\n')}`)\n}\n\nexport function createTagsFilter(tagsExpr: string[], availableTags: TestTagDefinition[]): (testTags: string[]) => boolean {\n  const matchers = tagsExpr.map(expr => parseTagsExpression(expr, availableTags))\n  return (testTags: string[]) => {\n    return matchers.every(matcher => matcher(testTags))\n  }\n}\n\ntype TagMatcher = (tags: string[]) => boolean\n\nfunction parseTagsExpression(expr: string, availableTags: TestTagDefinition[]): TagMatcher {\n  const tokens = tokenize(expr)\n  const stream = new TokenStream(tokens, expr)\n  const ast = parseOrExpression(stream, availableTags)\n  if (stream.peek().type !== 'EOF') {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/runtime/runner/utils/tags.ts#L23-L59","documentation":"Thrown by createNoTagsError when the config DOES define tags but the specific tag referenced by a test, suite, or CLI filter is not among them. Unlike error 340, this path lists the available tag names (with descriptions) to guide correction. It is reached from validateTags, suite.ts:322 (tag application), and resolveTagPattern (wildcard/non-wildcard filter resolution).","triggerScenarios":"config.tags is non-empty (e.g. [{name:'smoke'},{name:'integration'}]) but a test uses a tag not in that list, e.g. `{ tags: ['e2e'] }`. Also triggered by `--tag e2e` on the CLI, or a wildcard pattern like `--tag 'e2e-*'` that matches no declared tag.","commonSituations":"Typos in tag names (case or spelling); renaming a tag in config but not in tests; a tag added to a shared test file by one team that another team's config doesn't declare; wildcard patterns that don't match any declared tag.","solutions":["Read the 'Available tags are:' list in the error and use one of those exact names.","Add the missing tag to config.tags, e.g. append `{ name: 'e2e' }`.","Fix the typo / casing in the test's `tags` option to match a declared tag.","Set `strictTags: false` if loose tagging is acceptable for the project.","For wildcard filters, ensure the pattern matches at least one declared tag name."],"exampleFix":"// before — config declares 'integration' but test says 'integ'\ntest('db', { tags: ['integ'] }, () => {})\n\n// after\ntest('db', { tags: ['integration'] }, () => {})","handlingStrategy":"validation","validationCode":"import type { TestTagDefinition } from 'vitest'\nconst declared = new Set((config.tags ?? []).map((t: TestTagDefinition) => t.name))\nfunction assertKnownTag(tag: string) {\n  if (!declared.has(tag)) {\n    throw new Error(`Tag '${tag}' is not declared. Known: ${[...declared].join(', ')}`)\n  }\n}","typeGuard":"function isKnownTag(declared: ReadonlySet<string>, tag: string): boolean {\n  return declared.has(tag)\n}","tryCatchPattern":null,"preventionTips":["Derive a TypeScript union of allowed tag names from config.tags and type the `tags` option accordingly.","Keep tag names lowercase-kebab and document each in its TestTagDefinition.description.","When renaming a tag, grep the whole repo for the old name."],"tags":["config","tags","validation"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}