Skip to content

chore(test-runner): vendor the expect library#40301

Merged
dgozman merged 18 commits intomicrosoft:mainfrom
dgozman:vendor-expect
Apr 21, 2026
Merged

chore(test-runner): vendor the expect library#40301
dgozman merged 18 commits intomicrosoft:mainfrom
dgozman:vendor-expect

Conversation

@dgozman
Copy link
Copy Markdown
Collaborator

@dgozman dgozman commented Apr 19, 2026

Summary

  • Vendor the jest expect library (v30.2.0) into packages/playwright/src/matchers/expectLibrary.ts, adapted and trimmed to Playwright's needs.
  • Simplify surrounding glue: expect.ts rewritten on top of the vendored library, no more proxies, global variables, smaller interface into the test runner, etc.
  • Shaves ~200k from the expect bundle.

dgozman added 17 commits April 18, 2026 21:56
Inlines the parts of expect@30.2.0 that Playwright actually uses into
packages/playwright/src/matchers/expectLibrary.ts. Drops spy matchers,
jest snapshot matchers, expect.assertions/hasAssertions, and the public
addEqualityTesters API (matcher context keeps customTesters: [] so
built-in matcher bodies stay unchanged).

Removes the expect, @jest/get-type, and jest-util dependencies; inlines
getType, isPrimitive, isPromise locally.
Removes global state plumbing (getState/setState/JEST_MATCHERS_OBJECT),
dontThrow(), and unused MatcherState fields (currentTestName, testPath,
expand — expand was always false, so isExpand(this.expand) is now just
false). Unexports types and helpers that no caller imports.
Removes wrapUnknownMatcherProxy and the matching "helpful expect errors"
tests. Accessing a nonexistent matcher now yields the native "is not a
function" TypeError instead of a custom message.
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Member

@pavelfeldman pavelfeldman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's cleanup package.json - sounds like expect is being pulled via packages/playwright/package.json's dev deps - that is not orderly...

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chrome] › mcp/autowait.spec.ts:19 › racy navigation destroys context @mcp-windows-latest
❌ [chromium] › mcp/dashboard.spec.ts:156 › should start dashboard and annotate when no dashboard is running @mcp-windows-latest
❌ [firefox] › mcp/cli-json.spec.ts:171 › close after open returns closed status @mcp-windows-latest

2 flaky ⚠️ [chrome] › mcp/cdp.spec.ts:62 › should throw connection error and allow re-connecting `@mcp-windows-latest`
⚠️ [chrome] › mcp/cli-cdp.spec.ts:30 › cdp server `@mcp-windows-latest`

6429 passed, 976 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 1"

6 flaky ⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@ubuntu-22.04-chromium-tip-of-tree`
⚠️ [chromium-page] › page/page-request-continue.spec.ts:754 › propagate headers cross origin redirect after interception `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:647 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-22.04-node20`

41176 passed, 847 skipped


Merge workflow run.

@dgozman dgozman added the CQ1 label Apr 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests 2"

2 failed
❌ [firefox-library] › library/screencast.spec.ts:28 › screencast.start delivers frames via onFrame callback @firefox-headed-macos-15-xlarge
❌ [webkit-library] › library/capabilities.spec.ts:95 › should play audio @smoke @webkit-macos-15-large

75 flaky ⚠️ [chromium-library] › library/browsertype-connect.spec.ts:173 › launchServer › should ignore page.pause when headed `@chromium-macos-26-large`
⚠️ [chromium-library] › library/chromium/tracing.spec.ts:22 › should output a trace `@chromium-macos-26-large`
⚠️ [chromium-library] › library/video.spec.ts:647 › screencast › should capture full viewport `@chromium-macos-26-large`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-macos-26-large`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chrome-ubuntu-22.04`
⚠️ [chromium-library] › library/video.spec.ts:647 › screencast › should capture full viewport `@chromium-ubuntu-24.04`
⚠️ [chromium-library] › library/browsercontext-user-agent.spec.ts:110 › should work for navigator.userAgentData and sec-ch-ua headers `@msedge-macos-latest`
⚠️ [chromium-page] › page/locator-frame.spec.ts:272 › should work with COEP/COOP/CORP isolated iframe `@channel-chromium-macos-latest`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-windows-latest`
⚠️ [chromium-page] › page/workers.spec.ts:63 › should have timestamp on worker console messages `@chromium-windows-latest`
⚠️ [chromium-library] › library/video.spec.ts:682 › screencast › should capture full viewport on hidpi `@chromium-macos-15-xlarge`
⚠️ [chromium-library] › library/video.spec.ts:719 › screencast › should work with video+trace `@chromium-macos-15-xlarge`
⚠️ [chromium-library] › library/global-fetch-cookie.spec.ts:204 › should remove cookie with expires far in the past `@msedge-beta-macos-latest`
⚠️ [chromium-library] › library/global-fetch.spec.ts:359 › should not double stringify literal string undefined body when content-type is application/json `@chrome-beta-macos-latest`
⚠️ [chromium-library] › library/video.spec.ts:647 › screencast › should capture full viewport `@chromium-macos-26-xlarge`
⚠️ [chromium-library] › library/video.spec.ts:275 › screencast › should capture navigation `@chromium-tip-of-tree-ubuntu-22.04--headed`
⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chrome-macos-latest`
⚠️ [chromium-library] › library/browsercontext-fetch-algorithms.spec.ts:43 › algorithms › deflate decompression › should support decompression `@chrome-macos-latest`
⚠️ [chromium-library] › library/trace-viewer.spec.ts:1459 › should highlight locator in iframe while typing `@driver`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-macos-26-xlarge`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-macos-26-xlarge`
⚠️ [firefox-library] › library/page-close.spec.ts:152 › should not treat navigations as new popups `@firefox-headed-macos-15-xlarge`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-headed-ubuntu-24.04`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-beta-ubuntu-22.04`
⚠️ [firefox-page] › page/page-request-gc.spec.ts:19 › should work `@firefox-beta-ubuntu-22.04`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@tracing-firefox`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-beta-windows-latest`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@firefox-beta-windows-latest`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-beta-windows-latest`
⚠️ [firefox-library] › library/browsercontext-basic.spec.ts:36 › should be able to click across browser contexts `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/browsercontext-page-event.spec.ts:160 › should work with Shift-clicking `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/browsercontext-viewport.spec.ts:29 › should set the proper viewport size `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/debugger.spec.ts:68 › should run to location `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/download.spec.ts:357 › download event › should delete downloads on context destruction `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/screencast.spec.ts:55 › start throws if screencast is already started `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/screencast.spec.ts:179 › empty video `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/tracing.spec.ts:264 › should not include trace resources from the previous chunks `@firefox-headed-windows-latest`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-headed-windows-latest`
⚠️ [firefox-page] › page/page-wait-for-selector-2.spec.ts:47 › should not consider visible when zero-sized `@firefox-headed-windows-latest`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-ubuntu-24.04`
⚠️ [firefox-library] › library/browsertype-launch.spec.ts:95 › should handle exception `@firefox-macos-26-large`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-macos-26-large`
⚠️ [firefox-page] › page/page-select-option.spec.ts:386 › should wait for optgroup to be enabled `@firefox-macos-26-large`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-beta-macos-latest`
⚠️ [firefox-page] › page/page-wait-for-function.spec.ts:104 › should work with strict CSP policy `@firefox-beta-macos-latest`
⚠️ [firefox-library] › library/hit-target.spec.ts:259 › should not click an element overlaying iframe with the target `@firefox-macos-15-large`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-macos-15-large`
⚠️ [firefox-page] › page/page-click.spec.ts:1060 › should click a button that is overlaid by a permission popup `@firefox-macos-15-large`
⚠️ [firefox-page] › page/page-mouse.spec.ts:249 › should set modifier keys on click `@firefox-macos-15-large`
⚠️ [firefox-library] › library/browsercontext-reuse.spec.ts:200 › reuse launch › should not cache resources `@firefox-windows-latest`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@firefox-windows-latest`
⚠️ [firefox-page] › page/page-leaks.spec.ts:85 › click should not leak `@firefox-windows-latest`
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1080 › cli codegen › should not throw csp directive violation errors `@firefox-macos-15-xlarge`
⚠️ [webkit-library] › library/browsercontext-har.spec.ts:415 › should ignore boundary when matching multipart/form-data body `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsercontext-proxy.spec.ts:300 › should isolate proxy credentials between contexts `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsercontext-reuse.spec.ts:361 › reuse launch › should work with routeWebSocket `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsercontext-storage-state.spec.ts:262 › should not restore localStorage twice `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsercontext-timezone-id.spec.ts:88 › should not change default timezone in another context `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsercontext-user-agent.spec.ts:60 › should emulate device user-agent `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:514 › run-server › should save videos to artifactsDir `@webkit-macos-26-large`
⚠️ [webkit-library] › library/trace-viewer.spec.ts:425 › should filter network requests by resource type `@webkit-macos-26-large`
⚠️ [webkit-library] › library/video.spec.ts:439 › screencast › should be 800x450 by default `@webkit-macos-26-large`
⚠️ [webkit-page] › page/elementhandle-click.spec.ts:27 › should work with Node removed `@webkit-macos-26-large`
⚠️ [webkit-page] › page/elementhandle-content-frame.spec.ts:53 › should return null for document.documentElement `@webkit-macos-26-large`
⚠️ [webkit-page] › page/page-request-continue.spec.ts:192 › post data › should compute content-length from post data `@webkit-macos-26-large`
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:776 › run-server › should upload a folder `@webkit-headed-ubuntu-24.04`
⚠️ [webkit-library] › library/video.spec.ts:476 › screencast › should capture static page in persistent context @smoke `@webkit-headed-ubuntu-24.04`
⚠️ [webkit-library] › library/popup.spec.ts:261 › should not throw when click closes popup `@webkit-headed-windows-latest`
⚠️ [webkit-page] › page/page-drop.spec.ts:59 › should drop multiple file payloads `@webkit-headed-windows-latest`
⚠️ [webkit-page] › page/page-drop.spec.ts:71 › should drop a file by local path `@webkit-headed-windows-latest`
⚠️ [webkit-page] › page/page-event-console.spec.ts:228 › should have timestamp `@webkit-headed-windows-latest`
⚠️ [webkit-page] › page/wheel.spec.ts:135 › should set the modifiers `@webkit-headed-macos-15-xlarge`
⚠️ [webkit-page] › page/page-drop.spec.ts:96 › should drop files and data together `@webkit-windows-latest`
⚠️ [webkit-page] › page/page-autowaiting-basic.spec.ts:58 › should await form-get on click `@webkit-ubuntu-24.04`
⚠️ [webkit-library] › library/inspector/pause.spec.ts:169 › pause › should disable timeout on paused actions `@webkit-macos-15-large`

273272 passed, 12555 skipped


Merge workflow run.

@github-actions
Copy link
Copy Markdown
Contributor

Test results for "tests others"

2 fatal errors, not part of any test
1 failed
❌ [electron-api] › electron/electron-app.spec.ts:93 › should fire console events with handles and complex objects @electron-windows-latest

18674 passed, 617 skipped, 838 did not run


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants