Widen / expect-axe-playwright

Expect matchers to perform Axe accessibility tests in your Playwright tests.
ISC License
21 stars 5 forks source link

Require locators for assertions #5

Closed mskelton closed 2 years ago

mskelton commented 2 years ago

This library uses the expect-playwright model that I created to allow a page, frame, element handle, or locator (with automatic promise resolution). Given that we are removing support for jest-playwright in #4, let's also remove support for non-locator assertions.

The one exception here is if a page/frame is passed, let's automatically convert that to a locator to prevent projects from needing to do this:

-expect(page).toBeAccessible()
+expect(page.locator('body')).toBeAccessible()

We will remove element handles which are the main hangup due to handling them within frames. Page/frame support is easy enough, as we can determine if the provided handle is a locator, and if not we simply call .locator('body') before sending it along.