feat(web): locale and timezoneId options set the language and time zone every attempt runs in

Merged
OK
2mo ago
+177-15

Closes ENG-871. Feedback: the browser is always en-US, so an app that picks its language from navigator.language needs a localStorage write and a reload in every test.

  • web({ locale, timezoneId }) passes both to Playwright's context options (packages/web/src/surface.ts), so they hold on every context an attempt opens: the first one, after app.clearState(), and after a session restore.
  • Same semantics as Playwright's use.locale / use.timezoneId: context-creation options with no runtime setter. A target is the per-project unit, the same as Playwright projects. Per-test overrides (test.use) are a separate design question and left out.
  • Config-load validation (packages/web/src/engine.ts) rejects values Node's Intl accepts but Chromium refuses at context creation: und, x-private, +01:00, europe/berlin, utc. Aliases Chromium accepts (US/Eastern, GMT, Asia/Kolkata) still pass. Best effort: Node cannot tell us/eastern from US/Eastern, so for that case Chromium's Invalid timezone ID: us/eastern at the first context is what the user sees.
  • locale together with an accept-language entry in headers is INVALID_CONFIG, same as userAgent with user-agent: the header would win on the app's site while navigator.language reported the locale.
  • On a persistent context (connect.reconnectEndpoint, or a provider with scope: 'attempt') both options are INVALID_CONFIG, like headers, basicAuth, and userAgent. The error now names only the options that were set.
targets: [
  { name: 'de', engine: web({ locale: 'de-DE', timezoneId: 'Europe/Berlin' }), app },
],

Docs: web reference, browser guide, Kernel page, Playwright migration table (use.locale and use.timezoneId were "missing"), package README, skill setup table. Changeset: minor for @e2e-dev/web.

Verified

Ran it locally: yes

  • testbed, built CLI, a throwaway test reading navigator.language, the resolved time zone, and toLocaleString():
web({ locale: "de-DE", timezoneId: "Asia/Tokyo" })
{"language":"de-DE","timeZone":"Asia/Tokyo","formatted":"1.1.2026, 21:00:00"}
 ✓ page runs in the configured locale and time zone 182ms

web()  (control)
{"language":"en-US","timeZone":"Europe/Warsaw","formatted":"1/1/2026, 1:00:00 PM"}

web({ timezoneId: "Mars/Olympus" })
 ERROR  configuration error INVALID_CONFIG (config)
web({ timezoneId }) must be an IANA time zone such as "Europe/Berlin", got "Mars/Olympus"
  • Probed Playwright Chromium newContext with each edge value to set the validation rules above (Firefox and WebKit not installed locally).
  • New integration test (packages/web/tests/integration/protected-app.test.ts) checks language, time zone, and UTC offset before and after a context reset in real Chromium.