fix(e2e): let expect(await response.json()) reach the value matchers
Merged
KR
7d ago+32+32+01234567890123456789-9-9-0123456789
expect(await response.json()).toMatchSchema(schema) failed to type-check on the web engine's WebResponse:
TS2339: Property 'toMatchSchema' does not exist on type 'AsyncExpectation'.
json<T = unknown>(): Promise<T>infersTfrom its contextual type.expect's first overload was(actual: Locator), soTbecameLocatorand the call routed to the locator matchers.expect.softdid the same.- The locator and screen overloads are now generic (
<L extends Locator>(actual: NotAny<L>)). TypeScript infers nothing from a bare type parameter, sojson()keepsunknownand lands on the value overload.packages/e2e/src/types.ts:1011 NotAnykeepsanyoff the locator overload. A genericLwould otherwise matchany, and the DOMfetch(...).json()from the API testing guide would have regressed.json<T>()is unchanged, soconst users: User[] = await response.json()still infersT.
Closes ENG-974.
Verified
Ran it locally: yes
- Typechecked a scratch test in
apps/testbed(DOM lib) against the built packages, on main and on this branch:
expect(...) | main | this branch |
|---|---|---|
await response.json() (web engine) .toMatchSchema | TS2339 | ok |
expect.soft(await response.json()) .toMatchSchema | TS2339 | ok |
await (await fetch(url)).json() (DOM any) .toMatchSchema | ok | ok |
JSON.parse('[]') .toEqual | ok | ok |
const users: User[] = await response.json() | ok | ok |
locator, screen, browser, Locator | undefined routing | unchanged | unchanged |
sdk-types.tsgains the engine-response andanycases forexpectandexpect.soft. Both fail against the old overloads.- All 9 nightly examples (vite, next, astro, expo, swiftui, compose, kotlin-multiplatform, flutter, maui) pass
tsc --noEmitwith this branch's packede2e,@e2e-dev/web, and@e2e-dev/mobileswapped in.
Changes by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, via T3 Code.