-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Per-file opt-in isolation #8010
Description
Clear and concise description of the problem
--no-isolate is a great way to increase performance, drastically speeding things up in our large monorepo. However, we also have leaky files that mutate global state, which break other tests. It's inconvenient to fix all of these tests for us, and it would be very convenient if we could say "isolate just these test files". By far the biggest time sink for us with Vitest is the collect step, because basically every single file in the monorepo has to be re-imported for each test file.
It's not even really that we want those test files to be isolated themselves, we really just want the worker to be cleaned up after those test files, so that changes in that one file don't leak into other test files.
I think this would be a great middle ground for performance, where most tests that don't leak run quickly, and the few that need isolation can opt-in to it.
Suggested solution
Perhaps a comment like // @vitest-environment - // @vitest-isolate?
Alternative
I guess the config could have some sort of file matching regex as well, like environmentMatchGlobs (though that's deprecated I know)
Additional context
I know adding even more features and configuration isn't the best, but in the name of performance I think it would be worth it.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status