feat(web): locale and timezoneId options set the language and time zone every attempt runs in
Merged
OK
2mo ago+177+177+012345678901234567890123456789-15-15-01234567890123456789
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, afterapp.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 Playwrightprojects. Per-test overrides (test.use) are a separate design question and left out. - Config-load validation (
packages/web/src/engine.ts) rejects values Node'sIntlaccepts 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 tellus/easternfromUS/Eastern, so for that case Chromium'sInvalid timezone ID: us/easternat the first context is what the user sees. localetogether with anaccept-languageentry inheadersisINVALID_CONFIG, same asuserAgentwithuser-agent: the header would win on the app's site whilenavigator.languagereported the locale.- On a persistent context (
connect.reconnectEndpoint, or a provider withscope: 'attempt') both options areINVALID_CONFIG, likeheaders,basicAuth, anduserAgent. 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, andtoLocaleString():
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
newContextwith 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.