Skip to content

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

@1oglop1

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    P2 - 5

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions