Skip to content

fix(test): keep builtin expect matchers on base extend#41367

Merged
dgozman merged 1 commit into
microsoft:mainfrom
mturac:fix-41365-expect-extend-builtin-shadow
Jun 19, 2026
Merged

fix(test): keep builtin expect matchers on base extend#41367
dgozman merged 1 commit into
microsoft:mainfrom
mturac:fix-41365-expect-extend-builtin-shadow

Conversation

@mturac

@mturac mturac commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • keep uncaptured expect.extend() from installing custom matchers that shadow built-in matcher names on the base expect
  • preserve captured extended expect and mergeExpects() behavior for built-in-name overrides
  • add regressions for captured, uncaptured, and merged built-in matcher override paths

Fixes #41365.

Tests

  • npm run build
  • npm run ttest -- tests/playwright-test/expect.spec.ts --grep "(expect.extend should not override builtin matchers|expect.extend should fall back|expect.extend should be immutable|mergeExpects with builtin matcher overrides|should support mergeExpects$)"
  • npm run ttest -- tests/playwright-test/expect.spec.ts
  • npm run tsc -- --pretty false
  • npx eslint packages/playwright/src/matchers/expect.ts tests/playwright-test/expect.spec.ts
  • npm run lint-tests

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7354 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

2 flaky ⚠️ [chromium-library] › library/video.spec.ts:680 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/screenshot.spec.ts:289 › element screenshot › should restore default viewport after fullPage screenshot `@firefox-ubuntu-22.04-node20`

39618 passed, 744 skipped


Merge workflow run.

@dgozman dgozman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the fix, this looks great!

@dgozman dgozman merged commit f777a84 into microsoft:main Jun 19, 2026
46 checks passed
@MatthewbrennerOC

Copy link
Copy Markdown

Thank you for the quick fix! I am unfamiliar with the release cycle. When will this fix be applied?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Expect.Extend matcher with same name as default matcher in same expect instance overrides default matchers implementation to custom matcher

3 participants