Skip to content

Run behaviour for suites and tests using tags #5346

@JesusTheHun

Description

@JesusTheHun

Clear and concise description of the problem

I usually organize my tests per domain. Often, one domain can be tested in one file, so it can be picked using the CLI.
When a domain is too big so we try to split it into sub-domains, each being tested within a file.

And sometimes, those sub-domains cannot be tested concurrently, because they would conflict during integration tests with the database for example.

Suggested solution

Be able to add tags to tasks using object syntax :

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

Then using the CLI, I can pick or exclude tasks :

# 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

I realize that because there is an option -t / --testNamePattern, the name tag can cause some confusion and maybe there is a better name to be given to this tag system.

Alternative

Lock mechanism with the database. But vitest could schedule the tasks so they are less likely to block each others.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Rejected

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions