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
getMockedSystemTime() returns null if the fake time is specified using useFakeTimer({now: fakeTime}), while it correctly returns the mocked system time if using setSystemTime().
Reproduction
Run vitest with the following test:
import{vi,test,expect}from"vitest";test("Speicify with now",()=>{vi.useFakeTimers({now: 333});expect(vi.getMockedSystemTime()).toBeNull();// <---- Shouldn't be null})test("Speicify with setSystemTime",()=>{vi.useFakeTimers();vi.setSystemTime(333);expect(vi.getMockedSystemTime()?.getTime()).toBe(333);})
The test will pass, but the first test shouldn't pass.
Describe the bug
getMockedSystemTime()
returns null if the fake time is specified usinguseFakeTimer({now: fakeTime})
, while it correctly returns the mocked system time if usingsetSystemTime()
.Reproduction
Run vitest with the following test:
The test will pass, but the first test shouldn't pass.
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: