{"id":18219552,"url":"https://github.com/testing-library/pptr-testing-library","last_synced_at":"2025-05-16T13:02:47.021Z","repository":{"id":32648307,"uuid":"138259613","full_name":"testing-library/pptr-testing-library","owner":"testing-library","description":"puppeteer + dom-testing-library = 💖","archived":false,"fork":false,"pushed_at":"2024-03-07T17:51:48.000Z","size":1625,"stargazers_count":287,"open_issues_count":24,"forks_count":29,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T11:31:03.873Z","etag":null,"topics":["testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/testing-library.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-06-22T05:44:07.000Z","updated_at":"2025-03-30T00:44:47.000Z","dependencies_parsed_at":"2024-04-12T11:22:54.548Z","dependency_job_id":"afc568de-ccf8-481b-b002-a02ce47bdb3b","html_url":"https://github.com/testing-library/pptr-testing-library","commit_stats":{"total_commits":90,"total_committers":10,"mean_commits":9.0,"dds":0.3111111111111111,"last_synced_commit":"761f1208ada39eaa8c3308f0aabdd6ee63d82e06"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fpptr-testing-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fpptr-testing-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fpptr-testing-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/testing-library%2Fpptr-testing-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/testing-library","download_url":"https://codeload.github.com/testing-library/pptr-testing-library/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254535792,"owners_count":22087397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["testing"],"created_at":"2024-11-03T19:04:37.762Z","updated_at":"2025-05-16T13:02:46.996Z","avatar_url":"https://github.com/testing-library.png","language":"TypeScript","readme":"# pptr-testing-library\n\n[![NPM Package](https://badge.fury.io/js/pptr-testing-library.svg)](https://www.npmjs.com/package/pptr-testing-library)\n![GitHub Actions status](https://github.com/testing-library/pptr-testing-library/actions/workflows/ci.yml/badge.svg?branch=main)\n[![Dependencies](https://david-dm.org/testing-library/pptr-testing-library.svg)](https://david-dm.org/testing-library/pptr-testing-library)\n[![Discord](https://img.shields.io/discord/723559267868737556.svg?color=7389D8\u0026labelColor=6A7EC2\u0026logo=discord\u0026logoColor=ffffff)](https://discord.gg/testing-library)\n\n[puppeteer](https://github.com/GoogleChrome/puppeteer) + [@testing-library/dom](https://github.com/testing-library/dom-testing-library) = 💖\n\nAll your favorite user-centric querying functions from @testing-library/react \u0026 @testing-library/library available from Puppeteer!\n\n## Install\n\n`npm install --save-dev pptr-testing-library`\n\n## Use\n\n```js\nconst puppeteer = require('puppeteer')\nconst {getDocument, queries, waitFor} = require('pptr-testing-library')\n\nconst {getByTestId, getByLabelText} = queries\n\nconst browser = await puppeteer.launch()\nconst page = await browser.newPage()\n\n// Grab ElementHandle for document\nconst $document = await getDocument(page)\n// Your favorite query methods are available\nconst $form = await getByTestId($document, 'my-form')\n// returned elements are ElementHandles too!\nconst $email = await getByLabelText($form, 'Email')\n// interact with puppeteer like usual\nawait $email.type('pptr@example.com')\n// waiting works too!\nawait waitFor(() =\u003e getByText($document, 'Loading...'))\n```\n\nA little too un-puppeteer for you? We've got prototype-mucking covered too :)\n\n```js\nconst puppeteer = require('puppeteer')\nrequire('pptr-testing-library/extend')\n\nconst browser = await puppeteer.launch()\nconst page = await browser.newPage()\n\n// getDocument is added to prototype of Page\nconst $document = await page.getDocument()\n// query methods are added directly to prototype of ElementHandle\nconst $form = await $document.getByTestId('my-form')\n// destructing works if you explicitly call getQueriesForElement\nconst {getByText} = $form.getQueriesForElement()\n// ...\n```\n\n## Version Compat\n\n| Puppeteer Version | pptr-testing-library Version |\n| ----------------- | ---------------------------- |\n| 17+               | \u003e0.8.0                       |\n| \u003c17               | 0.7.x                        |\n\n## API\n\nUnique methods, not part of `@testing-library/dom`\n\n- `getDocument(page: puppeteer.Page): ElementHandle` - get an ElementHandle for the document\n- `wait(conditionFn: () =\u003e {}): Promise\u003c{}\u003e` - wait for the condition to not throw (wrapper around `waitForExpect`)\n\n---\n\n[@testing-library/dom API](https://github.com/testing-library/dom-testing-library#usage). All `get*`/`query*` methods are supported.\n\n- `getQueriesForElement(handle: ElementHandle): ElementHandle \u0026 QueryUtils` - extend the input object with the query API and return it\n- `getNodeText(handle: ElementHandle): Promise\u003cstring\u003e` - get the text content of the element\n- `queries: QueryUtils` - the query subset of `@testing-library/dom` exports\n  - `queryByPlaceholderText`\n  - `queryAllByPlaceholderText`\n  - `getByPlaceholderText`\n  - `getAllByPlaceholderText`\n  - `findByPlaceholderText`\n  - `findAllByPlaceholderText`\n  - `queryByText`\n  - `queryAllByText`\n  - `getByText`\n  - `getAllByText`\n  - `findByText`\n  - `findAllByText`\n  - `queryByLabelText`\n  - `queryAllByLabelText`\n  - `getByLabelText`\n  - `getAllByLabelText`\n  - `findByLabelText`\n  - `findAllByLabelText`\n  - `queryByAltText`\n  - `queryAllByAltText`\n  - `getByAltText`\n  - `getAllByAltText`\n  - `findByAltText`\n  - `findAllByAltText`\n  - `queryByTestId`\n  - `queryAllByTestId`\n  - `getByTestId`\n  - `getAllByTestId`\n  - `findByTestId`\n  - `findAllByTestId`\n  - `queryByTitle`\n  - `queryAllByTitle`\n  - `getByTitle`\n  - `getAllByTitle`\n  - `findByTitle`\n  - `findAllByTitle`\n  - `queryByRole`\n  - `queryAllByRole`\n  - `getByRole`\n  - `getAllByRole`\n  - `findByRole`\n  - `findAllByRole`\n  - `queryByDisplayValue`,\n  - `queryAllByDisplayValue`,\n  - `getByDisplayValue`,\n  - `getAllByDisplayValue`,\n  - `findByDisplayValue`,\n  - `findAllByDisplayValue`,\n\n## Known Limitations\n\n- Async utilities `waitForElement`, `waitForElementToBeRemoved` and `waitForDomChange` are not exposed. Consider using a `find*` query.\n- `fireEvent` method is not exposed, use puppeteer's built-ins instead.\n- `expect` assertion extensions are not available.\n\n## Special Thanks\n\n[@testing-library/dom](https://github.com/testing-library/dom-testing-library) of course!\n\n## Related Puppeteer Test Utilities\n\n- [jest-puppeteer](https://github.com/smooth-code/jest-puppeteer)\n- Yours! Name TBD, PR welcome ;)\n\n## LICENSE\n\nMIT\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesting-library%2Fpptr-testing-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftesting-library%2Fpptr-testing-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftesting-library%2Fpptr-testing-library/lists"}