xk6-browser icon indicating copy to clipboard operation
xk6-browser copied to clipboard

Implement extension to jslib `expect` library for xk6-browser

Open robingustafsson opened this issue 4 years ago • 0 comments

We want to start promoting the k6 expect library more for at least functional, contract validation and browser end-to-end testing, but probably also for load testing. Different types of tests need to verify, or expect, different things. In browser end-to-end testing you want to expect things like expect(element).toBeVisible() or expect(page.screenshot()).toMatchSnapshot('referenceScreenshot.js') (using https://github.com/mapbox/pixelmatch).

Here's a non-exhaustive list of expect extensions that we'd want:

  • expect(element).toBeChecked()
  • expect(element).toBeDisabled()
  • expect(element).toBeEditable()
  • expect(element).toBeEmpty()
  • expect(element).toBeEnabled()
  • expect(element).toBeFocused()
  • expect(element).toBeHidden()
  • expect(element).toBeUnchecked()
  • expect(element).toBeVisible()
  • expect(element).toContainText(text)
  • expect(element).toHaveAttribute(attribute)
  • expect(element).toHaveClass(class)
  • expect(element).toHaveCount(count)
  • expect(element).toHaveCSS(css)
  • expect(element).toHaveId(id)
  • expect(element).toHaveJSProperty(property)
  • expect(element|frame|page).toHaveText(text)
  • expect(frame|page).toHaveTitle(title)
  • expect(frame|page).toHaveURL(url)
  • expect(element).toHaveValue(value)
  • expect(element.screenshot()|page.screenshot()|ArrayBuffer).toMatchSnapshot(filename)

Relevant links:

  • Playwright code: https://github.com/microsoft/playwright/blob/master/packages/playwright-test/src/matchers/matchers.ts

robingustafsson avatar Nov 12 '21 09:11 robingustafsson