This release makes some significant changes to how tests are running. If you were using --no-threads
before, you might consider enabling --single-thread
instead (because your tests are now running in child_process
instead of a worker thread) or try our new performance optimization feature (discussed later). If you were relying on API that was not available inside a worker (like process.chdir()
, you can now use this option.
One of the potential breaking bug fixes is that environments do not share the same global scope anymore if you run them with --no-isolate
, --no-threads
or --single-thread
- you might need to update your setup files if you were relying on a global variable before.
If you had performance issues on large code bases before, try the new deps.experimentalOptimizer
option instead of disabling threads. Feedback is welcome!
One of the breaking changes includes adding a link to snapshots inside snapshot files, meaning you will need to update all your snapshots.
🚨 Breaking Changes
- Vitest as peer dependency for coverage packages - by @AriPerkkio in #2836 (94247)
- Coverage-c8 to use V8 profiler directly instead of
NODE_V8_COVERAGE
- by @AriPerkkio in #2786 (095c6) - Add a link to the comment at the top of the snapshot file - by @btea in #2867 (615e1)
- Always run separate environments in isolation - by @sheremet-va in #2860 (1f858)
- Tests with
node
andjsdom
(and other environments) now don't share the same global scope, if you run them with--no-isolate
or--no-threads
flag. Vitest doesn't provide a way to restore the previous behavior as it is considered a bug.
- Tests with
- Use child_process when --no-threads is used - by @sheremet-va in #2772 (7bf54)
- Tests inside
chid_process
might run longer due to the communication overhead. If you want to restore the previous behavior, use--single-thread
.
- Tests inside
🚀 Features
- Add test seed to banner - by @btkostner in #2877 (bdb39)
- Use custom source-map-support implementation - by @sheremet-va in #2905 (6ff6c)
- Add an option to enable Vite optimizer - by @sheremet-va in #2912 (af8de)
- coverage:
- Add support for coverage reporter options - by @AriPerkkio in #2690 (f8176)
- Automatic threshold updating - by @AriPerkkio in #2886 (e1652)
- spy:
- Implement mock.withImplementation API - by @obadakhalili and @sheremet-va in #2835 (610b1)
- vite-node:
🐞 Bug Fixes
- Wait for console.log to print a message before terminating a worker - by @sheremet-va in #2861 (fbc54)
- Cleanup last mocked cache when call vi.doMock - by @mysteryven in #2872 (65d71)
- Reload changed configuration file on watch mode - by @AriPerkkio in #2889 (4d277)
- coverage: Custom providers to work inside worker threads - by @AriPerkkio in #2817 (81604)