vitest-dev/vitest · error · Error
The " " is not defined in the configuration. Available tags…
Error message
The ${prefix} "${tag}" is not defined in the configuration. Available tags are:
${availableTags.map(t => `- ${t.name}${t.description ? `: ${t.description}` : ''}`).join('\n')} What it means
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).
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.
Example fix
// before — config declares 'integration' but test says 'integ'
test('db', { tags: ['integ'] }, () => {})
// after
test('db', { tags: ['integration'] }, () => {}) Defensive patterns
Strategy: validation
Validate before calling
import type { TestTagDefinition } from 'vitest'
const declared = new Set((config.tags ?? []).map((t: TestTagDefinition) => t.name))
function assertKnownTag(tag: string) {
if (!declared.has(tag)) {
throw new Error(`Tag '${tag}' is not declared. Known: ${[...declared].join(', ')}`)
}
} Type guard
function isKnownTag(declared: ReadonlySet<string>, tag: string): boolean {
return declared.has(tag)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Each tag defined in "test.tags" must have a "name"…
- Tag name " " is already defined in "test.tags". Tag names…
- Tag name " " is invalid. Tag names cannot contain spaces.
- Tag name " " is invalid. Tag names cannot be a logical…
- Tag name " " is invalid. Tag names cannot contain "!", "*"…
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/77816376d9815727.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vitest/src/runtime/runner/utils/tags.ts:41
export function validateTags(config: SerializedConfig, tags: string[]): void {
if (!config.strictTags) {
return
}
const availableTags = new Set(config.tags.map(tag => tag.name))
for (const tag of tags) {
if (!availableTags.has(tag)) {
throw createNoTagsError(config.tags, tag)
}
}
}
export function createNoTagsError(availableTags: TestTagDefinition[], tag: string, prefix = 'tag'): never {
if (!availableTags.length) {
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`)
}
throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:\n${availableTags
.map(t => `- ${t.name}${t.description ? `: ${t.description}` : ''}`)
.join('\n')}`)
}
export function createTagsFilter(tagsExpr: string[], availableTags: TestTagDefinition[]): (testTags: string[]) => boolean {
const matchers = tagsExpr.map(expr => parseTagsExpression(expr, availableTags))
return (testTags: string[]) => {
return matchers.every(matcher => matcher(testTags))
}
}
type TagMatcher = (tags: string[]) => boolean
function parseTagsExpression(expr: string, availableTags: TestTagDefinition[]): TagMatcher {
const tokens = tokenize(expr)
const stream = new TokenStream(tokens, expr)
const ast = parseOrExpression(stream, availableTags)
if (stream.peek().type !== 'EOF') {View on GitHub (pinned to 1fa9837ec2)