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
process.env.VITEST_WORKER_ID can be larger than maxThreads #1469
Comments
We have a different implementation for workers then Jest. Each spec file fires a different worker (unlike Jest), so for each one you get a number. When watch is triggered, a new worker is created with a unique number. |
I totally get the idea behind this. Is there any way to get an id based on |
Can you describe how you see it? Is it just |
Since |
#1473 introduces |
Beware that it will still change when editing file with |
Wow, that was quick! It's ok for me that it may change. Thank you! |
I am afraid that the current implementation (and my suggestion here is wrong. Imagine a use case where you have
In this scenario you have two threads with the same As a side note: The documentation already references |
I don't think we have information about when test actually starts and ends. We just fire them all at the same time, and |
Ah, I see. Mhhh, I will look into other possibilities to coordinate my test threads, but it's going to be way more complicated. I would suggest to revert this change then, because I think it does not help anybody. Thank you again for your swift reaction, I like vitest a lot so far. |
We will try to fix this in a few weeks. See #1482 |
|
Yes, it is! |
Describe the bug
We are migrating our Jest test code over to vitest. We use
process.env.JEST_WORKER_ID
to allocate a separate database for each worker/thread. With Jest thatJEST_WORKER_ID
is always between 1 and the maximum number of workers.In vitest
process.env.VITEST_WORKER_ID
seems to have another meaning and is ever increasing. The documentation states thatVITEST_WORKER_ID
can be used to distinguish between threads. In my opinion this is not what it actually does.Reproduction
Run any test-sutie and see that
VITEST_WORKER_ID
increases. In watch-mode it increases with each run.System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: