microsoft / playwright-test

Build a cross-browser end-to-end test suite with Playwright.
https://playwright.dev
Apache License 2.0
777 stars 34 forks source link

Add custom Jest matchers #44

Closed thernstig closed 4 years ago

thernstig commented 4 years ago

It would be cool to add custom Jest matchers by default to this lib. An example would be expect(page/element).toContainText('some text'), taking into account somehow the 3 different kind of text matchers text=example one (case-insensitive, substring matching), text="example 2" (exact matching), text=/^\\s*Some text$/i (regex matching).

Either in 3 separate functions, or just one matcher with all variants.

Also an expect(page/element).toContainElement (or expect(page/element).toContainSelector which underneath calls waitForSelector.

JoelEinbinder commented 4 years ago

I think this is the same core idea as #41. Definitely a good idea. Let's keep high level discussion in that issue, and file new issues for specific api proposals.