Skip to content

[Reconsider] Run behaviour for suites and tests using tags / marks #8672

Description

@1oglop1

Clear and concise description of the problem

I come from Pytest, and simply marking tests is a feature I greatly miss in most test frameworks.
There is one rejected proposal #5346; however, with v4 being around the corner, it would be great to reconsider.

The similar functionality for selecting tests is almost already there with only()

Suggested solution

// existing functionality
it.only('test', () => {})
test.skipIf(isDev)('prod only test', () => {})

// A
test.tags('domain1').it('should filter the data correctly', async () => { /* ... */});
// B
test.tags('domain1')('should filter the data correctly', async () => { /* ... */});

// extended A
test.tags('domain1').skipIf(isDev).it('should filter the data correctly', async () => { /* ... */});
// extended B
test.tags('domain1').skipIf(isDev)('should filter the data correctly', async () => { /* ... */});

Original proposal

test('should filter the data correctly', { tags: ['domain1'] }, async () => { /* ... */});
# Run tests for tasks having the tag "api" or "auth"
vitest --run --tag api --tag auth

# Run tests for tasks having the tag "api" and "auth"
vitest --run --tag api auth

# Pick test files that contain the word "user", exclude the tasks having the tag "api"
vitest user --run --no-tag api

# Prevent tasks with the tag "database" to be run in parallel
vitest --run --tag api --no-tag-parallelism database

Additional context

Validations

Activity

  1. added theissue type on Oct 7, 2025
  2. moved this to P2 - 5 in Team Boardon Dec 23, 2025
  3. moved this from P2 - 5 to Approved in Team Boardon Jan 9, 2026
  4. sheremet-va commented on Jan 13, 2026

    @sheremet-va
    Member

    The team decided to support tags, but we prefer the original proposal:

    test('should filter the data correctly', { tags: ['domain1'] }, async () => { /* ... */});
    
    vitest --tag api --tag auth
    

    The tags should also be defined in the config file. Vitest will check that test tags are the same as the ones in the config file, and throw an error otherwise:

    export default defineConfig({
      test: {
        tags: [
          { name: 'api', description: 'API tests' }, // maybe support TestOptions like "concurrent", "timeout", etc too
          { name: 'auth' },
        ],
      },
    })

    Tags should also be supported by project.createSpecification

  5. self-assigned this
    on Jan 16, 2026
  6. locked and limited conversation to collaborators on Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

p2-nice-to-haveNot breaking anything but nice to have (priority)

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions