New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: support running tests using VM context #3203
Conversation
Run & review this pull request in StackBlitz Codeflow. |
will that help with |
If you need speed, don't use Current version of this PR uses only workers to run tests in parallel. Will probably add a way to run |
Yeah I wish but in Lerna-Lite (a fork of Lerna), it uses a ton of
that would be really nice and I wonder if that would help with my opened issue #3129 that I still have and found no fix yet (apart from not running the test one at a time). I did migrate from Jest to Vitest regardless |
c3edc0d
to
fd56878
Compare
With this third runner environment option, I wonder if the config should be refactored to replace |
Yes, I've been thinking about a similar approach. But technically it should also contain "browser". The list might be:
We decided against it for now to keep the same API. The |
What's a |
|
Thanks, that does sound awesome indeed to be finally able to stop fighting jsdom 👍 |
4e22f76
to
3bc676b
Compare
5a45332
to
7f4a3df
Compare
39e9855
to
939c81d
Compare
I think we also need to implement |
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
6929bca
to
62bcb35
Compare
aka bring all Jest (V8) bugs into Vitest
The idea is to have a separate pool that will spawn workers with tinypool, but they will not be isolated. Isolation is introduced by
vm.createContext
inside the worker. For this, we need to implement our ownimport
handling. I think we should keep our__vitest_ssr_import__
because it is the only way to support both ESM/CJS in the same file in wrongly bundled dependencies.This is an optional pool! You need to opt-in to use it:
via CLI argument:
--experimental-vm-threads
(this will throw an error, if you use--threads
or--browser
at the same time)via config option:
run only a subset of files using this pool with
poolMatchGlob
You also cannot disable isolation when using
experimentalVm
, because this doesn't make sense with this pool. If you don't need isolation, usethreads
orchild_process
directly.vm
has a notable memory leak problem, so we are also introducingexperimentalVmWorkerMemoryLimit
option (works like Jest's workerIdleMemoryLimit to destroy the worker before it reaches this point. It is set tomax_heap/number_of_workers
by default. You might have better performance if you tweak this value manually.--experimental-vm-child-process
(experimentalVmChildProcess
) will be implemented in a separate PR.Pros:
Cons:
vm
modules nodejs/node#31658Breaking changes:
transformMode
(web
orssr
). If transform mode is not specified, it will throw an error