@@ -118,13 +118,14 @@ expect(page.get_by_test_id("current-time")).to_have_text("2/2/2024, 10:30:00 AM"
118
118
``` java
119
119
// Initialize clock with some time before the test time and let the page load
120
120
// naturally. `Date.now` will progress as the timers fire.
121
- page. clock(). install(new Clock .InstallOptions (). setTime(Instant . parse(" 2024-02-02T08:00:00" )));
121
+ SimpleDateFormat format = new SimpleDateFormat (" yyy-MM-dd'T'HH:mm:ss" );
122
+ page. clock(). install(new Clock .InstallOptions (). setTime(format. parse(" 2024-02-02T08:00:00" )));
122
123
page. navigate(" http://localhost:3333" );
123
124
Locator locator = page. getByTestId(" current-time" );
124
125
125
126
// Pretend that the user closed the laptop lid and opened it again at 10am.
126
127
// Pause the time once reached that point.
127
- page. clock(). pauseAt(Instant . parse(" 2024-02-02T10:00:00" ));
128
+ page. clock(). pauseAt(format . parse(" 2024-02-02T10:00:00" ));
128
129
129
130
// Assert the page state.
130
131
assertThat(locator). hasText(" 2/2/2024, 10:00:00 AM" );
@@ -315,15 +316,16 @@ expect(locator).to_have_text("2/2/2024, 10:00:02 AM")
315
316
```
316
317
317
318
``` java
319
+ SimpleDateFormat format = new SimpleDateFormat (" yyy-MM-dd'T'HH:mm:ss" );
318
320
// Initialize clock with a specific time, let the page load naturally.
319
321
page. clock(). install(new Clock .InstallOptions ()
320
- .setTime(Instant . parse(" 2024-02-02T08:00:00" )));
322
+ .setTime(format . parse(" 2024-02-02T08:00:00" )));
321
323
page. navigate(" http://localhost:3333" );
322
324
Locator locator = page. getByTestId(" current-time" );
323
325
324
326
// Pause the time flow, stop the timers, you now have manual control
325
327
// over the page time.
326
- page. clock(). pauseAt(Instant . parse(" 2024-02-02T10:00:00" ));
328
+ page. clock(). pauseAt(format . parse(" 2024-02-02T10:00:00" ));
327
329
assertThat(locator). hasText(" 2/2/2024, 10:00:00 AM" );
328
330
329
331
// Tick through time manually, firing all timers in the process.
0 commit comments