
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
pptr-testing-library
Advanced tools
puppeteer + @testing-library/dom = 💖
All your favorite user-centric querying functions from @testing-library/react & @testing-library/library available from Puppeteer!
npm install --save-dev pptr-testing-library
const puppeteer = require('puppeteer')
const {getDocument, queries, waitFor} = require('pptr-testing-library')
const {getByTestId, getByLabelText} = queries
const browser = await puppeteer.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 puppeteer like usual
await $email.type('pptr@example.com')
// waiting works too!
await waitFor(() => getByText($document, 'Loading...'))
A little too un-puppeteer for you? We've got prototype-mucking covered too :)
const puppeteer = require('puppeteer')
require('pptr-testing-library/extend')
const browser = await puppeteer.launch()
const page = await browser.newPage()
// getDocument is added to prototype of Page
const $document = await page.getDocument()
// query methods are added directly to prototype of ElementHandle
const $form = await $document.getByTestId('my-form')
// destructing works if you explicitly call getQueriesForElement
const {getByText} = $form.getQueriesForElement()
// ...
| Puppeteer Version | pptr-testing-library Version |
|---|---|
| 17+ | >0.8.0 |
| <17 | 0.7.x |
Unique methods, not part of @testing-library/dom
getDocument(page: puppeteer.Page): ElementHandle - get an ElementHandle for the documentwait(conditionFn: () => {}): Promise<{}> - wait for the condition to not throw (wrapper around waitForExpect)@testing-library/dom API. All get*/query* 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
queryByPlaceholderTextqueryAllByPlaceholderTextgetByPlaceholderTextgetAllByPlaceholderTextfindByPlaceholderTextfindAllByPlaceholderTextqueryByTextqueryAllByTextgetByTextgetAllByTextfindByTextfindAllByTextqueryByLabelTextqueryAllByLabelTextgetByLabelTextgetAllByLabelTextfindByLabelTextfindAllByLabelTextqueryByAltTextqueryAllByAltTextgetByAltTextgetAllByAltTextfindByAltTextfindAllByAltTextqueryByTestIdqueryAllByTestIdgetByTestIdgetAllByTestIdfindByTestIdfindAllByTestIdqueryByTitlequeryAllByTitlegetByTitlegetAllByTitlefindByTitlefindAllByTitlequeryByRolequeryAllByRolegetByRolegetAllByRolefindByRolefindAllByRolequeryByDisplayValue,queryAllByDisplayValue,getByDisplayValue,getAllByDisplayValue,findByDisplayValue,findAllByDisplayValue,waitForElement, waitForElementToBeRemoved and waitForDomChange are not exposed. Consider using a find* query.fireEvent method is not exposed, use puppeteer's built-ins instead.expect assertion extensions are not available.@testing-library/dom of course!
MIT
FAQs
puppeteer + dom-testing-library
The npm package pptr-testing-library receives a total of 33,720 weekly downloads. As such, pptr-testing-library popularity was classified as popular.
We found that pptr-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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.