66 isServe ,
77 page ,
88 untilBrowserLogAfter ,
9- untilUpdated ,
109 viteTestUrl ,
1110} from '~utils'
1211
@@ -24,25 +23,26 @@ test.runIf(isServe)('should hmr', async () => {
2423 editFile ( 'App.jsx' , ( code ) =>
2524 code . replace ( 'Vite + React' , 'Vite + React Updated' ) ,
2625 )
27- await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React Updated' )
26+ await expect
27+ . poll ( ( ) => page . textContent ( 'h1' ) )
28+ . toMatch ( 'Hello Vite + React Updated' )
2829 // preserve state
2930 expect ( await page . textContent ( '#state-button' ) ) . toMatch ( 'count is: 1' )
3031
3132 editFile ( 'App.jsx' , ( code ) =>
3233 code . replace ( 'Vite + React Updated' , 'Vite + React' ) ,
3334 )
34- await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React' )
35+ await expect . poll ( ( ) => page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
3536} )
3637
3738test . runIf ( isServe ) ( 'should not invalidate when code is invalid' , async ( ) => {
3839 editFile ( 'App.jsx' , ( code ) =>
3940 code . replace ( '<div className="App">' , '<div className="App"}>' ) ,
4041 )
4142
42- await untilUpdated (
43- ( ) => page . textContent ( 'vite-error-overlay .message-body' ) ,
44- 'Unexpected token' ,
45- )
43+ await expect
44+ . poll ( ( ) => page . textContent ( 'vite-error-overlay .message-body' ) )
45+ . toMatch ( 'Unexpected token' )
4646 // if import.meta.invalidate happened, the old page won't be shown because the page is reloaded
4747 expect ( await page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
4848
@@ -90,7 +90,7 @@ if (!isBuild) {
9090 'Parent rendered' ,
9191 ] ,
9292 )
93- await untilUpdated ( ( ) => page . textContent ( '#parent' ) , 'Updated' )
93+ await expect . poll ( ( ) => page . textContent ( '#parent' ) ) . toMatch ( 'Updated' )
9494 } )
9595
9696 // #3301
@@ -122,10 +122,9 @@ if (!isBuild) {
122122 'Parent rendered' ,
123123 ] ,
124124 )
125- await untilUpdated (
126- ( ) => page . textContent ( '#context-provider' ) ,
127- 'context provider updated' ,
128- )
125+ await expect
126+ . poll ( ( ) => page . textContent ( '#context-provider' ) )
127+ . toMatch ( 'context provider updated' )
129128 } )
130129
131130 test ( 'should hmr files with "react/jsx-runtime"' , async ( ) => {
@@ -143,10 +142,9 @@ if (!isBuild) {
143142 ) ,
144143 [ '[vite] hot updated: /hmr/jsx-import-runtime.js' ] ,
145144 )
146- await untilUpdated (
147- ( ) => page . textContent ( '#jsx-import-runtime' ) ,
148- 'JSX import runtime updated' ,
149- )
145+ await expect
146+ . poll ( ( ) => page . textContent ( '#jsx-import-runtime' ) )
147+ . toMatch ( 'JSX import runtime updated' )
150148
151149 expect ( await page . textContent ( '#state-button' ) ) . toMatch ( 'count is: 1' )
152150 } )
0 commit comments