microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65k stars 3.54k forks source link

[Bug]: Playwright with 'jest-extended' matchers error #31595

Closed andrii-nastenko closed 1 month ago

andrii-nastenko commented 1 month ago

Version

1.45.0

Steps to reproduce

preconditions:

Install packages:

1) "@playwright/test": "1.45.0" 2) "jest-extended": "4.0.2"

Create and apply following files into your project:

matchers.ts

import * as JestExtendedMatchersMethods from 'jest-extended';

expect.extend(JestExtendedMatchersMethods.default);

export {expect};

matchers-types.d.ts

declare global {
  namespace PlaywrightTest {
    interface Matchers<R, T> extends jest.Matchers<R> {}
  }
}

export {};

use jest matcher in some test, e.g.

expect(someArray).toIncludeAllMembers([1,2,3,4,5]);

Expected behavior

Matcher should work and pass check

Actual behavior

TypeError: equals is not a function

Additional context

Important thing:

Matchers from 'jest-extended' package has always worked with previous PW versions (e.g. it worked with previous 1.44.1). The problem appeared stating with 1.45.0 version.

Environment

packages:

"@playwright/test": "1.45.0"
"jest-extended": "4.0.2"

OS: macos sonoma 14.4.1

Package manager: yarn 1.22.21

Node: v18.12.0
mxschmitt commented 1 month ago

Investigation:

mxschmitt commented 1 month ago

Playwright Expect is not the same as Jest Expect, see here.

dgozman commented 1 month ago

Capturing offline discussion: introduce equals() method that will throw a nice message pointing to the docs.