Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
playwright-testing-library
Advanced tools
🔍 Find elements in playwright like your users with queries from @testing-library/dom
All of your favorite user-centric querying functions from @testing-library/react and @testing-library/dom available from Playwright!
@playwright-testing-library/test/fixture
or...playwright-testing-library
/@playwright-testing-library/test
# 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
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('playwright@example.com')
// ...
})
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('playwright@example.com')
// ...
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*
, query*
, and find*
methods are supported.
getQueriesForElement(handle: ElementHandle): ElementHandle & QueryUtils
- extend the input object with the query API and return itgetNodeText(handle: ElementHandle): Promise<string>
- get the text content of the elementqueries: 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
,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.MIT
This project is actively maintained by engineers at @hoverinc 😀.
FAQs
playwright + dom-testing-library
The npm package playwright-testing-library receives a total of 1,118 weekly downloads. As such, playwright-testing-library popularity was classified as popular.
We found that playwright-testing-library demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.