Skip to content

Commit 91a98ad

Browse files
committed
playwright: Use @sinonjs/fake-timers on the test runner side too
1 parent f8bab04 commit 91a98ad

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

e2e/helper.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { test as base } from '@playwright/test';
22
import type { MockServiceWorker } from 'playwright-msw';
3-
import { http, HttpResponse } from 'msw';
43
import { createWorker } from 'playwright-msw';
54
import { db, handlers } from '@crates-io/msw';
65

6+
import * as pwFakeTimers from '@sinonjs/fake-timers';
77
import { FakeTimers, FakeTimersOptions } from './fixtures/fake-timers';
88
import { MiragePage } from './fixtures/mirage';
99
import { PercyPage } from './fixtures/percy';
@@ -33,11 +33,23 @@ export const test = base.extend<AppOptions & AppFixtures>({
3333
emberOptions: [{ setTesting: true, mockSentry: true }, { option: true }],
3434
clock: [
3535
async ({ page, clockOptions }, use) => {
36+
let now = clockOptions.now;
37+
if (typeof now === 'string') {
38+
now = Date.parse(now);
39+
}
40+
41+
let pwClock = pwFakeTimers.install({
42+
...clockOptions,
43+
now,
44+
toFake: ['Date'],
45+
});
46+
3647
let clock = new FakeTimers(page);
3748
if (clockOptions != null) {
3849
await clock.setup(clockOptions);
3950
}
4051
await use(clock);
52+
pwClock?.uninstall();
4153
},
4254
{ auto: true, scope: 'test' },
4355
],

0 commit comments

Comments
 (0)