This repository was archived by the owner on Aug 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,15 @@ test.describe('lib/fixture.ts (locators)', () => {
214
214
expect ( await locator . textContent ( ) ) . toEqual ( 'Loaded!' )
215
215
} )
216
216
217
+ test ( "queryBy* methods can be used with Playwright's laziness" , async ( { screen, within} ) => {
218
+ const modalLocator = await screen . findByRole ( 'dialog' , undefined , { timeout : 3000 } )
219
+
220
+ await expect ( modalLocator ) . toHaveText ( / M y M o d a l / )
221
+ await within ( modalLocator ) . getByRole ( 'button' , { name : 'Okay' } ) . click ( )
222
+
223
+ await expect ( screen . queryByRole ( 'dialog' ) ) . toBeHidden ( )
224
+ } )
225
+
217
226
test ( 'should handle the findAllBy* methods' , async ( { queries} ) => {
218
227
const locator = await queries . findAllByText ( / H e l l o / , undefined , { timeout : 3000 } )
219
228
Original file line number Diff line number Diff line change 25
25
attached . textContent = 'Attached'
26
26
attached . style . visibility = 'hidden'
27
27
document . body . appendChild ( attached )
28
+
29
+ const modal = document . createElement ( 'dialog' )
30
+ const modalButton = document . createElement ( 'button' )
31
+ const modalHeader = document . createElement ( 'h1' )
32
+
33
+ modal . style . display = 'block'
34
+
35
+ modalButton . innerText = 'Okay'
36
+ modalButton . onclick = ( ) => {
37
+ modal . innerText = 'Doing a thing...'
38
+ setTimeout ( ( ) => document . querySelector ( 'dialog' ) . remove ( ) , 1000 )
39
+ }
40
+
41
+ modalHeader . innerText = 'My Modal'
42
+
43
+ modal . appendChild ( modalButton )
44
+ modal . appendChild ( modalHeader )
45
+
46
+ document . body . appendChild ( modal )
28
47
} , 2000 )
29
48
</ script >
30
49
</ body >
You can’t perform that action at this time.
0 commit comments