API …
Dynamic & timing

Flaky state & time

Clock-dependent text, leaking storage, random data, viewport and locale differences and slow transitions.

Practice tasks

  • Freeze the clock with await page.clock.install({ time: new Date('2026-03-08T09:30:00') }) and assert “Good morning” deterministically.
  • Fast-forward the session countdown with page.clock.fastForward(30000) and assert the “Extend session” button appears.
  • Make the welcome-tour test order-independent: fresh browser context per test, or storageState with the tour already dismissed.
  • Assert the generated e-mail with a regex (/^[a-z]+\.[a-z]+\d{3}@example\.test$/) and then repeat with a seed for an exact match.
  • Run the viewport test at 1280×720 and at 390×844 with page.setViewportSize() and assert the right navigation element each time.
  • Pin locale: 'en-US' and timezoneId: 'UTC' in playwright.config and assert the formatted currency and date.
  • Wait for the transition with expect(panel).toHaveCSS('opacity', '1') (retrying), then compare with a fixed sleep.

More Dynamic & timing practice