1- # playwright-testing-library
1+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
4+ - [ playwright-testing-library] ( #playwright-testing-library )
5+ - [ ✨ Features] ( #-features )
6+ - [ 🌱 Getting Started] ( #-getting-started )
7+ - [ 1. Install] ( #1-install )
8+ - [ 2a. Use _ standalone queries_ ] ( #2a-use-_standalone-queries_ )
9+ - [ 2b. Use _ extensions_ ] ( #2b-use-_extensions_ )
10+ - [ 🔌 API] ( #-api )
11+ - [ Known Limitations] ( #known-limitations )
12+ - [ Special Thanks] ( #special-thanks )
13+ - [ Related Playwright Test Utilities] ( #related-playwright-test-utilities )
14+ - [ LICENSE] ( #license )
15+
16+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
17+
18+ <div align =" center " >
19+ <br >
20+ <header >
21+ <img src="https://user-images.githubusercontent.com/288160/126050717-dd76eb80-ef06-40e0-97e8-72c20c9f8f20.png" height="64" />
22+ </header >
23+ <br >
24+ <h1 >playwright-testing-library</h1 >
25+ <p >🔍 Find elements in <strong >playwright</strong > like your users will with <strong >@testing-libary/dom</strong ></p >
26+ </div >
27+
28+ <div align =" center " >
229
330[ ![ Package Version] [ npm-badge ]] [ npm-link ]
431[ ![ Build Status] [ travis-badge ]] [ travis-link ]
532[ ![ Test Coverage] [ codecov-badge ]] [ codecov-link ]
633[ ![ Dependencies Status] [ david-badge ]] [ david-link ]
34+ [ ![ MIT License] [ license-badge ]] [ license-link ] <br >
35+ [ ![ Code Style] [ prettier-badge ]] [ prettier-link ]
736[ ![ Conventional Commits] [ conventional-commits-badge ]] [ conventional-commits-link ]
37+ [ ![ Maintenance] [ maintenance-badge ]] [ maintenance-link ]
38+
39+ </div >
840
9- [ playwright ] ( https://github.com/microsoft/playwright ) + [ @ testing-library/dom ] ( https://github.com/testing-library/dom-testing-library ) = 💖
41+ < br >
1042
11- All your favorite user-centric querying functions from ** @ testing-library/react ** & ** @ testing-library/library ** available from Playwright!
43+ ## ✨ Features
1244
1345> ⚠️ Note: this is a fork of [ pptr-testing-library] ( https://github.com/testing-library/pptr-testing-library ) modified to accomodate for some subtle API differences.
1446
15- ## Contents
47+ All of your favorite user-centric querying functions from ** @ testing-library/react ** and ** @ testing-library/dom ** available from Playwright!
1648
17- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
18- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
49+ - Standalone queries — ** ` playwright-testing-library ` ** or...
50+ - Playwright extensions — ** ` playwright-testing-library/extend ` **
51+ - Asynchronous assertion helper (via ** [ wait-for-expect] ( https://github.com/TheBrainFamily/wait-for-expect ) ** )
1952
20- - [ Install] ( #install )
21- - [ Use] ( #use )
22- - [ API] ( #api )
23- - [ Known Limitations] ( #known-limitations )
24- - [ Special Thanks] ( #special-thanks )
25- - [ Related Playwright Test Utilities] ( #related-playwright-test-utilities )
26- - [ LICENSE] ( #license )
53+ ## 🌱 Getting Started
2754
28- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
55+ ### 1. Install
56+
57+ ``` bash
58+ npm install --save-dev playwright-testing-library
59+ ```
2960
30- ## Install
61+ or
3162
32- ` npm install --save-dev playwright-testing-library `
63+ ``` bash
64+ yarn add --dev playwright-testing-library
65+ ```
3366
34- ## Use
67+ ### 2a. Use _ standalone queries _
3568
3669``` js
3770const {webkit } = require (' playwright' ) // or 'firefox' or 'chromium'
@@ -54,7 +87,7 @@ await $email.type('playwright@example.com')
5487await waitFor (() => getByText ($document, ' Loading...' ))
5588```
5689
57- A little too un-playwright for you? We've got prototype-mucking covered too :)
90+ ### 2b. Use _ extensions _
5891
5992``` js
6093const {webkit } = require (' playwright' ) // or 'firefox' or 'chromium'
@@ -63,6 +96,8 @@ require('playwright-testing-library/extend')
6396const browser = await webkit .launch ()
6497const page = await browser .newPage ()
6598
99+ deCall (' editor.action.formatDocument' )
100+ // getDocument is added to prototype of Page
66101// getDocument is added to prototype of Page
67102const $document = await page .getDocument ()
68103// query methods are added directly to prototype of ElementHandle
@@ -72,16 +107,29 @@ const {getByText} = $form.getQueriesForElement()
72107// ...
73108```
74109
75- ## API
110+ ## 🔌 API
111+
112+ Unique methods, not part of ** @testing-library/dom **
76113
77- Unique methods, not part of ` @testing-library/dom `
114+ - Get an ` ElementHandle ` for the document
78115
79- - ` getDocument(page: playwright.Page): ElementHandle ` - get an ElementHandle for the document
80- - ` wait(conditionFn: () => {}): Promise<{}> ` - wait for the condition to not throw (wrapper around ` waitForExpect ` )
116+ ``` ts
117+ getDocument (page : playwright .Page ): ElementHandle
118+ ```
119+
120+ - Wait for an assertion (wrapper around [ wait-for-expect] ( https://github.com/TheBrainFamily/wait-for-expect ) )
121+
122+ ``` ts
123+ waitFor (
124+ expectation : () => void | Promise < void > ,
125+ timeout ?: number ,
126+ interval ?: number
127+ ): Promise < {}>
128+ ```
81129
82130---
83131
84- [ @testing-library/dom API ] ( https://github.com/testing-library/dom-testing-library#usage ) . All ` get* ` / ` query* ` methods are supported.
132+ The ** [ @testing-library/dom ] ( https://github.com/testing-library/dom-testing-library#usage ) ** — All ** ` get* ` ** and ** ` query* ` ** methods are supported.
85133
86134- ` getQueriesForElement(handle: ElementHandle): ElementHandle & QueryUtils ` - extend the input object with the query API and return it
87135- ` getNodeText(handle: ElementHandle): Promise<string> ` - get the text content of the element
@@ -150,13 +198,19 @@ Unique methods, not part of `@testing-library/dom`
150198
151199MIT
152200
153- [ npm-link ] : https://www.npmjs.com/package/playwright-testing-library
154- [ npm-badge ] : https://img.shields.io/npm/v/playwright-testing-library
155- [ travis-link ] : https://travis-ci.org/github/hoverinc/playwright-testing-library
156- [ travis-badge ] : https://travis-ci.org/hoverinc/playwright-testing-library.svg?branch=main
157- [ codecov-link ] : https://codecov.io/gh/hoverinc/playwright-testing-library
158201[ codecov-badge ] : https://codecov.io/gh/hoverinc/playwright-testing-library/branch/main/graph/badge.svg
159- [ conventional-commits- link] : https://conventionalcommits.org
202+ [ codecov- link] : https://codecov.io/gh/hoverinc/playwright-testing-library
160203[ conventional-commits-badge ] : https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
161- [ david- link] : https://david-dm .org/hoverinc/playwright-testing-library
204+ [ conventional-commits- link] : https://conventionalcommits .org
162205[ david-badge ] : https://david-dm.org/hoverinc/playwright-testing-library.svg
206+ [ david-link ] : https://david-dm.org/hoverinc/playwright-testing-library
207+ [ license-badge ] : https://img.shields.io/npm/l/@hover/javascript.svg
208+ [ license-link ] : https://github.com/hoverinc/hover-javascript/blob/master/LICENSE
209+ [ maintenance-badge ] : https://img.shields.io/badge/maintenance-active-247ddc?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAcCAYAAACUJBTQAAAB1ElEQVRIibWWPUtdQRCGH0VNF/wCCVjYCxr/gZWdhYVgLQYbm/wACTYxxA8SSBDtbKwUbfQWkiJFAgkkmHBBY6U2CXaCGlDDG1buxePOnt17bsgD28zOzjtnZvbuRVKR1SFpVdKepEe1njOGnOWCz0q60B1lSa05/oVE2iTNSfqdCZ7lSyWB0NmkSJekeUmXJqzlayWZUJxckUUTJs23mFAjlhNjSdMHfAQ6g54hZUnDdXyN44ek7iKNH4w0PMaeX7pQ8Ox6HQkWww3Dw1hPWoAJ4BxoB4aNR5oB4APQ5vekUdITSceZDLcreyORrGPcfpEL0CBpVNJRwLmUSWLS7NbGpju8FXEteT2qR+jQ9aS3QK2XgUljjXPpRC6iLpYV4KmxRghNVy28Aqb+t4jjLbBhrAH+RcRxZSwBUiINxlIHKZE/xlIHTTlHBDwHjoDPwHtgF/gEnBnvFJVfzSrXkpYyfxKGvIu14F3ONXP1LOWmzEPjpuWl92j55XyQyDnEjRN5AbwD9gMOPkV7tAPMOJE3ZuuOFmOpjS3gGfCdQDl8fgGnGVtzwt8F7wdGqgKOvOmq4iarB3gMjAFlb78qug5MAwehIO4tKViJe4wDP4FSrgfwF/ntR8JxRSf3AAAAAElFTkSuQmCC
210+ [ maintenance-link ] : https://github.com/hoverinc/hover-javascript#maintenance
211+ [ npm-badge ] : https://img.shields.io/npm/v/playwright-testing-library
212+ [ npm-link ] : https://www.npmjs.com/package/playwright-testing-library
213+ [ prettier-badge ] : https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier
214+ [ prettier-link ] : https://prettierjs.org/en/download/
215+ [ travis-badge ] : https://travis-ci.org/hoverinc/playwright-testing-library.svg?branch=main
216+ [ travis-link ] : https://travis-ci.org/github/hoverinc/playwright-testing-library
0 commit comments