You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's cumbersome and error prone to accept expect for each concurrent test
Automatic tracking is also allows to make tests faster by using .concurrent wrapper, without code modifications
import{describe,it}from'vitest'// All tests within this suite will be run in paralleldescribe.concurrent('suite',()=>{it('concurrent test 1',async({ expect })=>{/* ... */})it('concurrent test 2',async({ expect })=>{/* ... */})it.concurrent('concurrent test 3',async({ expect })=>{/* ... */})})
Suggested solution
We can add opt in option to use AsyncLocalStorage for node.
We cannot use AsyncLocalStorage in core since it's a Node.js API. Vitest runner also runs in the browser and should have the same API surface. The best we can do is wait until the context API is standardized.
As a workaround, you can wrap it functions yourself. You can also extend Vitest runner with runner option or use a custom task function.
Another thing I wanted to mention is that using { expect } from a concurrent test is required only and exclusively for snapshot testing and expect.assertions methods.
Normally, expect doesn't need to know the current test - it just throws an error based on the input.
Automatic expect tracking for concurrent tests
It's cumbersome and error prone to accept
expect
for each concurrent testAutomatic tracking is also allows to make tests faster by using
.concurrent
wrapper, without code modificationsSuggested solution
We can add opt in option to use AsyncLocalStorage for node.
Alternative
Zone.js can be also used for async context tracking, since it monkeypatches a lot of stuff - it less reliable
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: