Skip to navigation

v5.7.0

New features

  • The mockRequest action answers matching browser requests with a response you define, until the test ends. The request never reaches the server. Use it to show stable data in screenshots or to test how a page handles an error. Filter by URL glob and, optionally, by HTTP method. mockRequest works in Chrome. Other browsers skip the step.
  • The saveState and loadState actions save the open site’s cookies and localStorage to a JSON file and load them in a later test. You then sign in once instead of in every test. The file uses Playwright’s storageState format. saveState doesn’t replace an existing file unless you set overwrite. The file holds live session cookies and tokens, so keep it out of version control and uploaded CI artifacts. See Pages behind a sign-in.
  • The totp(secret) expression returns the current one-time code for a base32 secret, the code an authenticator app shows. A test can then sign in to an account that uses two-factor authentication. See Function operators and Sign in with a one-time code.
  • A context’s browser can set what the page sees about the user’s device: colorScheme, locale, timezone, deviceScaleFactor, reducedMotion, and clock. Chrome sets every key, and Firefox sets every key except timezone and clock. A context that asks for a key its browser can’t set reports SKIPPED. See Page emulation.

Behavior changes

  • Chrome sessions now use a different browser connection, which mockRequest and the timezone and clock settings need. Firefox and Safari sessions are unchanged.

Bug fixes

  • saveCookie keeps each cookie’s httpOnly flag, so loadCookie restores the cookie as it was saved. Cookie files are readable only by your user account, and a save never leaves a partly written file.