Skip to content

Commit b77cde9

Browse files
committed
mock time
1 parent 2e13b5f commit b77cde9

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

apps/zbugs/src/local-mutate.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {expect, test} from 'vitest';
1+
import {expect, test, vi, beforeEach, afterEach} from 'vitest';
22
import {zeroForTest} from '@rocicorp/zero/testing';
33
import {builder, schema} from '../shared/schema.ts';
44
import {mutators} from '../shared/mutators.ts';
@@ -27,6 +27,15 @@ const mutatorsForTest = defineMutators(mutators, {
2727
},
2828
});
2929

30+
beforeEach(() => {
31+
vi.useFakeTimers();
32+
vi.setSystemTime(new Date('2025-01-15T12:00:00Z'));
33+
});
34+
35+
afterEach(() => {
36+
vi.useRealTimers();
37+
});
38+
3039
test('local mutate', async () => {
3140
const zero = zeroForTest({
3241
cacheURL: null,
@@ -64,11 +73,11 @@ test('local mutate', async () => {
6473
[
6574
{
6675
"assigneeID": null,
67-
"created": 1768845460229,
76+
"created": 1736942400000,
6877
"creatorID": "user-1",
6978
"description": "This is a test issue",
7079
"id": "issue-1",
71-
"modified": 1768845460229,
80+
"modified": 1736942400000,
7281
"open": true,
7382
"projectID": "project-1",
7483
"shortID": null,

0 commit comments

Comments
 (0)