All Projects → testing-library → playwright-testing-library

testing-library / playwright-testing-library

Licence: MIT license
🔍 Find elements in Playwright with queries from Testing Library

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to playwright-testing-library

Jest Dom
🦉 Custom jest matchers to test the state of the DOM
Stars: ✭ 2,908 (+1717.5%)
Mutual labels:  testing-library, dom-testing-library
test-real-styles
(test-)framework agnostic utilities to test real styling of (virtual) dom elements
Stars: ✭ 37 (-76.87%)
Mutual labels:  testing-library, playwright
toUUID
Simple integer to UUID generator for unit and integration tests written in Java or Kotlin
Stars: ✭ 12 (-92.5%)
Mutual labels:  integration-testing, testing-library
playwright-fluent
Fluent API around playwright
Stars: ✭ 71 (-55.62%)
Mutual labels:  testing-library, playwright
api-test
🌿 A simple bash script to test JSON API from terminal in a structured and organized way.
Stars: ✭ 53 (-66.87%)
Mutual labels:  integration-testing, testing-library
playwright-jest-boilerplate
No description or website provided.
Stars: ✭ 16 (-90%)
Mutual labels:  playwright
playwright-vscode
Playwright Test Visual Studio Code integration
Stars: ✭ 144 (-10%)
Mutual labels:  playwright
nodejs-integration-testing
Integration testing of a Node.js / Express.js / Sequelize app
Stars: ✭ 23 (-85.62%)
Mutual labels:  integration-testing
react-github-profile
Learning about (unit & integration) testing on React
Stars: ✭ 19 (-88.12%)
Mutual labels:  testing-library
Recorder
A browser extension that generates Cypress, Playwright and Puppeteer test scripts from your interactions 🖱 ⌨
Stars: ✭ 277 (+73.13%)
Mutual labels:  playwright
axe-playwright
♿: Custom commands for Playwright to run accessibility (a11y) checks with axe-core
Stars: ✭ 88 (-45%)
Mutual labels:  playwright
duct
docker-compose alike functionality directly from golang, for integration testing.
Stars: ✭ 61 (-61.87%)
Mutual labels:  integration-testing
Beef
Business Entity Execution Framework
Stars: ✭ 95 (-40.62%)
Mutual labels:  integration-testing
playwright-session
Visual Debugger for Playwright automation.
Stars: ✭ 39 (-75.62%)
Mutual labels:  playwright
molecule-demo
Molecule for Ansible Role Testing Demonstration for AnsibleFest 2017
Stars: ✭ 18 (-88.75%)
Mutual labels:  integration-testing
jest-puppeteer-istanbul
Collect code coverage information from end-to-end jest puppeteer tests
Stars: ✭ 26 (-83.75%)
Mutual labels:  integration-testing
Madara
✍️ A way for people to manage their tasks.
Stars: ✭ 17 (-89.37%)
Mutual labels:  testing-library
maven-it-extension
Experimental JUnit Jupiter Extension for writing integration tests for Maven plugins/Maven extensions/Maven Core
Stars: ✭ 56 (-65%)
Mutual labels:  integration-testing
docker-compose-integration-tests
Writing integration tests in Java using docker-compose and JUnit
Stars: ✭ 21 (-86.87%)
Mutual labels:  integration-testing
browser-pool
A Node.js library to easily manage and rotate a pool of web browsers, using any of the popular browser automation libraries like Puppeteer, Playwright, or SecretAgent.
Stars: ✭ 71 (-55.62%)
Mutual labels:  playwright


playwright-testing-library

🔍 Find elements in playwright like your users with queries from @testing-library/dom

Build Status Test Coverage Code Style Package Version
MIT License Conventional Commits Maintenance


Features

⚠️ Note: this is a fork of pptr-testing-library modified to accomodate for some subtle API differences.

All of your favorite user-centric querying functions from @testing-library/react and @testing-library/dom available from Playwright!

  • Playwright Test fixture@playwright-testing-library/test/fixture or...
  • Standalone queries — playwright-testing-library/@playwright-testing-library/test
  • Asynchronous assertion helper (via wait-for-expect)

🌱 Getting Started

1. Install

# For use with Playwright
npm install --save-dev playwright-testing-library

# For use with Playwright Test
npm install --save-dev @playwright-testing-library/test

or

# For use with Playwright
yarn add --dev playwright-testing-library

# For use with Playwright Test
yarn add --dev @playwright-testing-library/test

2a. Use Playwright Test fixture

import {test as baseTest} from '@playwright/test'
import {fixtures, within, TestingLibraryFixtures} from '@playwright-testing-library/test/fixture'

// As only fixture
const test = baseTest.extend<TestingLibraryFixtures>(fixtures)

// Alternatively, with other fixtures
interface Fixtures extends TestingLibraryFixtures {
  // ... additional fixture types
}

const test = baseTest.extend<Fixtures>({
  ...fixtures,
  // ... additional fixtures
})

const {expect} = test

// Query methods are available in `test` blocks
test('my form', async ({queries: {getByTestId}}) => {
  const $form = await getByTestId('my-form')

  // Scope queries with `within`
  const {getByLabelText} = within($form)

  const $email = await getByLabelText('Email')

  // Interact with Playwright like usual
  await $email.type('[email protected]')

  // ...
})

2b. Use standalone queries

const {webkit} = require('playwright') // or 'firefox' or 'chromium'
const {getDocument, queries} = require('playwright-testing-library')

const {getByTestId, getByLabelText} = queries

const browser = await webkit.launch()
const page = await browser.newPage()

// Grab ElementHandle for document
const $document = await getDocument(page)

// Your favorite query methods are available
const $form = await getByTestId($document, 'my-form')

// Returned elements are ElementHandles too!
const $email = await getByLabelText($form, 'Email')

// Interact with playwright like usual
await $email.type('[email protected]')

// ...

🔌 API

Unique methods, not part of @testing-library/dom

  • Get an ElementHandle for the document

    getDocument(page: playwright.Page): ElementHandle
  • Wait for an assertion (wrapper around wait-for-expect)

    waitFor(
      expectation: () => void | Promise<void>,
      timeout?: number,
      interval?: number
    ): Promise<{}>

The @testing-library/dom — All get* and query* methods are supported.

  • getQueriesForElement(handle: ElementHandle): ElementHandle & QueryUtils - extend the input object with the query API and return it
  • getNodeText(handle: ElementHandle): Promise<string> - get the text content of the element
  • queries: QueryUtils - the query subset of @testing-library/dom exports
    • queryByPlaceholderText
    • queryAllByPlaceholderText
    • getByPlaceholderText
    • getAllByPlaceholderText
    • findByPlaceholderText
    • findAllByPlaceholderText
    • queryByText
    • queryAllByText
    • getByText
    • getAllByText
    • findByText
    • findAllByText
    • queryByLabelText
    • queryAllByLabelText
    • getByLabelText
    • getAllByLabelText
    • findByLabelText
    • findAllByLabelText
    • queryByAltText
    • queryAllByAltText
    • getByAltText
    • getAllByAltText
    • findByAltText
    • findAllByAltText
    • queryByTestId
    • queryAllByTestId
    • getByTestId
    • getAllByTestId
    • findByTestId
    • findAllByTestId
    • queryByTitle
    • queryAllByTitle
    • getByTitle
    • getAllByTitle
    • findByTitle
    • findAllByTitle
    • queryByDisplayValue,
    • queryAllByDisplayValue,
    • getByDisplayValue,
    • getAllByDisplayValue,
    • findByDisplayValue,
    • findAllByDisplayValue,

Known Limitations

  • Async utilities waitForElement, waitForElementToBeRemoved and waitForDomChange are not exposed. Consider using a find* query.
  • fireEvent method is not exposed, use Playwright's built-ins instead.
  • expect assertion extensions are not available.

Special Thanks

Related Playwright Test Utilities

LICENSE

MIT

Maintenance

This project is actively maintained by engineers at @hoverinc 😀.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].