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
Currently, jest useFakeTimers has the option to pass { doNotFake: <SomeTimerFacet>} to prevent fake timers from faking specific apis/functions like setTimeOut etc.
vitest provides the toFake option where you can explicitly decide which apis and functions to mock, but for things like usage with msw v2 where we cannot fake queueMicrotask, but would like to fake everything else, this means I have to explicitly specify every other FakeMethod in toFake when using vi.useFakeTimers.
Suggested solution
Implement the doNotFake option so one can simply write vi.useFakeTimers({ doNotFake: queueMicrotask }) and get the desired result of faking every other FakeMethod
Alternative
Currently we just create a const with every other FakeMethod and pass it to toFake. This is a fine workaround, but not a satisfactory one as it's a large list.
Even just exporting the FakeMethod type would be a great help.
Vitest exposes fakeTimersDefaults from vitest/config. In the future, we won't specify toFake values, they will be implied from the environment: #6288 Then it will have doNotFake option.
Clear and concise description of the problem
Currently, jest useFakeTimers has the option to pass
{ doNotFake: <SomeTimerFacet>}
to prevent fake timers from faking specific apis/functions likesetTimeOut
etc.vitest
provides thetoFake
option where you can explicitly decide which apis and functions to mock, but for things like usage with msw v2 where we cannot fakequeueMicrotask
, but would like to fake everything else, this means I have to explicitly specify every otherFakeMethod
intoFake
when usingvi.useFakeTimers
.Suggested solution
Implement the
doNotFake
option so one can simply writevi.useFakeTimers({ doNotFake: queueMicrotask })
and get the desired result of faking every otherFakeMethod
Alternative
Currently we just create a
const
with every otherFakeMethod
and pass it to toFake. This is a fine workaround, but not a satisfactory one as it's a large list.Even just exporting the
FakeMethod
type would be a great help.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: