File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import { test as base } from '@playwright/test' ;
22import type { MockServiceWorker } from 'playwright-msw' ;
3- import { http , HttpResponse } from 'msw' ;
43import { createWorker } from 'playwright-msw' ;
54import { db , handlers } from '@crates-io/msw' ;
65
6+ import * as pwFakeTimers from '@sinonjs/fake-timers' ;
77import { FakeTimers , FakeTimersOptions } from './fixtures/fake-timers' ;
88import { MiragePage } from './fixtures/mirage' ;
99import { 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 ] ,
You can’t perform that action at this time.
0 commit comments