Skip to content

Releases: playwright-community/expect-playwright

Version 0.8.0

19 Aug 15:48
af26cd0
Compare
Choose a tag to compare

Add support for Locators! Playwright 1.14 recently released the Locators API which now work when passed to expect-playwright matchers:

await expect(page.locator('button')).toBeEnabled()

Version 0.7.2

06 Jul 13:00
Compare
Choose a tag to compare

Changes:

  • fix: toHaveSelector when ElementHandle is passed (#118)

Version 0.7.1

02 Jul 15:47
Compare
Choose a tag to compare

Bug fixes

Fixes an issue in version 0.7.0 where the package output format was unintentionally changed which led to expect-playwright not working.

Version 0.7.0

02 Jul 09:34
Compare
Choose a tag to compare

New features

  • Add toMatchComputedStyle matcher to match against computed CSS styles (#112)
  • Add promise support to selector matchers to not require awaits inside the expect statement anymore (#113)

Other updates

  • Add toMatchAttribute to the documentation (#111)
  • Improve toHaveFocus. This works now with frames, element handles and promise based variants of them (#114)
  • Update internal iframe tests to have better internal end-to-end tests (#115)

Version 0.6.0

28 Jun 22:59
Compare
Choose a tag to compare

A lot has changed in expect-playwright and we are happy to bring you version 0.6.0 with new matchers, automatic promise resolution, improvements to not.toHaveSelector, and error message diffs!

New matchers!

This release brings 7 new matchers to simplify even more common testing use cases. Below is a quick summary of each new matcher we've added, but checkout the docs for full details showing how to use these new matchers.

  • toBeChecked - Checks if a checkbox or radio is checked.
  • toBeDisabled - Checks if an element is disabled.
  • toBeEnabled - Checks if an element is enabled.
  • toMatchAttribute - Checks if an element's attribute matches a given string or regex pattern.
  • toMatchTitle - Checks if the page or frame title matches a given string or regex pattern.
  • toMatchURL - Checks if the page or frame URL matches a given string or regex pattern.
  • toMatchValue - Checks if an element's value matches a given string or regex pattern.

Automatic promise resolution

A recent change allows all expect-playwright matchers to accept a promise which resolves to a page, frame, or element handle so you are not forced to write extra awaits in your tests!

// before
await expect(await page.$('button')).toBeChecked()

// after
await expect(page.$('button')).toBeChecked()

Improved not.toHaveSelector

Previously, using not.toHaveSelector would wait for 30 second (or the specified timeout) for an element to appear and if it did not appear after that timeout, it would cause the test to pass. While this worked okay, it introduced lots of extra wait time in tests that is often unwanted. The two workarounds were to pass a shorter timeout, or use toHaveSelector(selector, { state: "hidden" }).

However, neither of these workarounds were ideal so we decided to update the defaults to make not.toHaveSelector more useful. Now, when calling not.toHaveSelector, we will wait for the element to be hidden after which your test will continue. This results in more reliable and faster tests!

Error message diffs

Error messages will now display a diff when the expected/received values are similar to help you more easily pinpoint why your tests failed.

123365020-13636580-d53b-11eb-8659-ca72760d9537

Deprecations

Previously, we had several matchers with toEqual and toHave variations for exact/substring matching. For example, toEqualText would check if an elements text matched a given string exactly, while toHaveText would verify the element's text contained the given string. With our new toMatch matchers, passing a string will perform an exact match, and passing a regex will perform a regex based match. As such, we are deprecating our toEqual and toHave matchers since our new toMatch matchers cover both use cases.

Below is an example showing the migration path for toEqualText and toHaveText.

// before
await expect(element).toEqualText('foo')
await expect(element).toHaveText('bar')

// after
await expect(element).toMatchText('foo')
await expect(element).toMatchText(/bar/)

Acknowledgement

Many thanks to @mskelton for putting so much effort into this package and bringing its feature-set and quality to the next level! ❤️

Version 0.5.1

20 Jun 12:54
Compare
Choose a tag to compare

Fixes:

  • fix: add toMatchText to exported matchers (#88)

Version 0.5.0

19 Jun 10:24
Compare
Choose a tag to compare

Changes:

  • feat: allow iframe handle as arg to toEqualText and toEqualUrl (#86)
  • feat: toMatchText | Add method to verify that an element or page text matches the given pattern. (#81)

Special thanks to @pjcalvo and @mskelton ❤️

Version 0.4.1

09 Jun 19:21
Compare
Choose a tag to compare

Changes:

  • fix: make it compatible with playwright-test (#79)
  • Bump dependencies, update ws (#80)
  • fix: export matchers from package (#83)

Version 0.4.0

08 Jun 09:32
Compare
Choose a tag to compare

Changes:

  • chore: update dependencies (#70)
  • chore: add Prettier (#72)
  • feat: improve toEqualText error message and refactor tests (#73)
  • chore: improve toEqualUrl and toEqualValue matcher messages (#75)
  • chore: Improved matcher message for selector matchers (#76)
  • chore: finish matcher updates (#77)

Many thanks to @mskelton for adding the new diff visualization.

Version 0.3.4

20 Apr 11:04
Compare
Choose a tag to compare
  • Bump dependencies
  • Add ability to handle Frame #66 #68