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)', () => {
214214 expect ( await locator . textContent ( ) ) . toEqual ( 'Loaded!' )
215215 } )
216216
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+
217226 test ( 'should handle the findAllBy* methods' , async ( { queries} ) => {
218227 const locator = await queries . findAllByText ( / H e l l o / , undefined , { timeout : 3000 } )
219228
Original file line number Diff line number Diff line change 2525 attached . textContent = 'Attached'
2626 attached . style . visibility = 'hidden'
2727 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 )
2847 } , 2000 )
2948 </ script >
3049 </ body >
You can’t perform that action at this time.
0 commit comments