File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,30 @@ <h2>Usefull snippets</h2>
5858
5959 test . use ( { actionTimeout : 2000 } ) ;
6060 await page . waitForTimeout ( 50 ) ;
61+ await expect . poll ( async ( ) => {
62+ const selectedItems = await querySelector ( page , selector ) ;
63+ return await selectedItems . innerHTML ( ) ;
64+ } ) . toEqual ( data ) ;
65+ await expect . poll ( async ( ) => {
66+ return await page . locator ( '.status-message' ) . textContent ( ) ;
67+ } , {
68+ // Custom message if it times out
69+ message : 'The status message did not update in time' ,
70+ // Total time to keep trying (in milliseconds)
71+ timeout : 10000 ,
72+ // How long to wait between attempts
73+ intervals : [ 500 , 1000 , 2000 ] ,
74+ } ) . toEqual ( 'Success' ) ;
75+ await expect ( async ( ) => {
76+ const selectedItems = await querySelector ( page , selector ) ;
77+ const content = await selectedItems . innerHTML ( ) ;
78+
79+ // A standard assertion inside the block
80+ expect ( content ) . toEqual ( data ) ;
81+ } ) . toPass ( {
82+ timeout : 10000 ,
83+ intervals : [ 500 ]
84+ } ) ;
6185
6286 // extra step for codegen
6387 await expect ( page . locator ( "body" ) ) . toHaveCount ( 1 ) ;
You can’t perform that action at this time.
0 commit comments