Skip to content

Commit 66cdbe3

Browse files
committed
fix setSystemTime typo
1 parent 2bf2a8c commit 66cdbe3

File tree

1 file changed

+2
-2
lines changed
  • exercises/03.date-and-time/01.solution.date-time

1 file changed

+2
-2
lines changed

exercises/03.date-and-time/01.solution.date-time/README.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ afterAll(() => {
1818

1919
Calling `vi.useFakeTimers()` detached this test from the real flow of time, and makes it rely on the internal fake date Vitest has. Correspondingly, the `vi.useRealTimers()` utility undoes that.
2020

21-
To fix date and time in test, I will call `vi.useSystemTime()` function and provide it with the date that I want to be treated as `Date.now()`:
21+
To fix date and time in test, I will call `vi.setSystemTime()` function and provide it with the date that I want to be treated as `Date.now()`:
2222

2323
```ts filename=get-relative-time.test.ts nonumber lines=2
2424
test('returns "Just now" for the current date', () => {
2525
vi.setSystemTime(new Date('2024-06-01 00:00:00.000Z'))
2626
```
2727
28-
> :owl: `vi.useSystemTime()` only works in conjunction with `vi.useFakeTimers()`.
28+
> :owl: `vi.setSystemTime()` only works in conjunction with `vi.useFakeTimers()`.
2929
3030
In order to model the "Just now" scenario, the delta between the current time and the start time has to be 60 seconds or less. In this test, I will pass the exact same date to the `getRelativeTime()` function as the system time:
3131

0 commit comments

Comments
 (0)