Test Tags in Vitest

From the Vitest cheat sheet ยท Filtering & Tags ยท verified Nov 2026

Test Tags

Label tests with shared options and filter runs with tag expressions (4.1+)

typescript
// vitest.config.ts
test: {
  tags: [
    { name: 'db', timeout: 60_000 },
    { name: 'flaky', retry: process.env.CI ? 2 : 0 },
  ],
}

// user.test.ts
test('saves a user', { tags: ['db'] }, async () => { /* ... */ })

// vitest run --tags-filter=db
๐Ÿ“Œ Tags arrived in 4.1; undeclared tags fail unless strictTags is off
๐Ÿ’ก Put timeout and retry on a tag instead of repeating them per test
โšก --tags-filter accepts !, && (and) and || (or) expressions
๐Ÿ” Use tags for categories, projects for different runtime settings
tagsfilter

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet