{"id":"75b4f4a14d4692c8","repo":"vitest-dev/vitest","slug":"the-vitest-config-does-t-define-any-tags-cannot","errorCode":null,"errorMessage":"The Vitest config does't define any \"tags\", cannot apply \"${tag}\" ${prefix} for this test. See: https://vitest.dev/guide/test-tags","messagePattern":"The Vitest config does't define any \"tags\", cannot apply \"(.+?)\" (.+?) for this test\\. See: https://vitest\\.dev/guide/test-tags","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vitest/src/runtime/runner/utils/tags.ts","lineNumber":39,"sourceCode":"  return tagsFilterPredicate(testTags)\n}\n\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)","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/vitest-dev/vitest/blob/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/vitest/src/runtime/runner/utils/tags.ts#L21-L57","documentation":"`createNoTagsError` (tags.ts:37-44) is invoked when `strictTags` is enabled and a test/suite references a tag not defined in the config's `tags` array. When the config defines zero tags at all, this specific message is shown (the more detailed 'available tags' list variant is used when tags exist but the referenced one isn't among them). It directs the user to declare tags in config first.","triggerScenarios":"Setting `strictTags: true` in the Vitest config with an empty (or absent) `tags` array, then using `test('x', () => {}, { tags: ['slow'] })` or `describe('g', { tags: ['slow'] }, () => {})`. Also triggered by tag filter expressions referencing undefined tags.","commonSituations":"Enabling strictTags without first defining any tags in config; typos in tag names; copying tag usage from another project without importing its tag definitions; using tag-based filtering (`--tag`) before configuring tags.","solutions":["Define tags in your Vitest config: `test: { tags: [{ name: 'slow', description: '...' }] }`.","Disable `strictTags` if you want undeclared tags to be allowed.","Fix typos in the tag name to match a defined tag exactly.","Refer to https://vitest.dev/guide/test-tags for the tags configuration schema."],"exampleFix":"// before: vitest.config.ts\nexport default defineConfig({\n  test: { strictTags: true /* no tags defined */ },\n})\n// test file\ntest('slow test', () => {}, { tags: ['slow'] }) // throws\n// after: vitest.config.ts\nexport default defineConfig({\n  test: {\n    strictTags: true,\n    tags: [{ name: 'slow', description: 'Long-running tests' }],\n  },\n})","handlingStrategy":"validation","validationCode":"import type { TestTagDefinition } from 'vitest'\nfunction tagIsDefined(config: { tags?: TestTagDefinition[] }, tag: string): boolean {\n  return (config.tags ?? []).some(t => t.name === tag)\n}\n// before using a tag in a test:\nif (!tagIsDefined(vitestConfig, 'slow')) {\n  throw new Error('Define \"slow\" in config.test.tags or disable strictTags')\n}","typeGuard":"function configHasTags(config: { tags?: TestTagDefinition[] }): config is { tags: TestTagDefinition[] } {\n  return Array.isArray(config.tags) && config.tags.length > 0\n}","tryCatchPattern":null,"preventionTips":["Define every tag you reference in config.test.tags before enabling strictTags.","Keep a single source of truth for tag names and import it in both config and tests.","Disable strictTags if undeclared tags should be tolerated."],"tags":["tags","config","stricttags","validation"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}