Skip to content

Unit tests fail on parallel execution on Vitest v4 #1565

@jescalada

Description

@jescalada

When running unit tests in parallel, either locally or on the CI, tests often fail or are flaky:

Image

This can be reproduced by simply setting fileParallelism to true on vitest.config.ts, or by running npm run test-shuffle.

This was a known issue during/after our Mocha to Vitest migration (#1202, #1294), and we ultimately covered it up by running tests sequentially. The proper solution, requiring more effort, is to refactor our tests so that state is cleaned up correctly, and tests are truly atomic - in other words always pass even when executed randomly or in parallel.

Describe the solution you'd like
Refactoring any problematic unit and integration tests so that we can set fileParallelism: true on both vitest.config.ts and vitest.config.integration.ts.

Ideally, code coverage loss should be kept to a minimum, and if any tests are removed they should be replaced another one with similar intent and covered lines.

Additional context
Vitest migration PR: #1202
Related failing proxy tests post-migration: #1294
Vitest v4 upgrade which brought this problem to my attention #1564

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions