6
6
isServe ,
7
7
page ,
8
8
untilBrowserLogAfter ,
9
- untilUpdated ,
10
9
viteTestUrl ,
11
10
} from '~utils'
12
11
@@ -24,25 +23,26 @@ test.runIf(isServe)('should hmr', async () => {
24
23
editFile ( 'App.jsx' , ( code ) =>
25
24
code . replace ( 'Vite + React' , 'Vite + React Updated' ) ,
26
25
)
27
- await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React Updated' )
26
+ await expect
27
+ . poll ( ( ) => page . textContent ( 'h1' ) )
28
+ . toMatch ( 'Hello Vite + React Updated' )
28
29
// preserve state
29
30
expect ( await page . textContent ( '#state-button' ) ) . toMatch ( 'count is: 1' )
30
31
31
32
editFile ( 'App.jsx' , ( code ) =>
32
33
code . replace ( 'Vite + React Updated' , 'Vite + React' ) ,
33
34
)
34
- await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React' )
35
+ await expect . poll ( ( ) => page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
35
36
} )
36
37
37
38
test . runIf ( isServe ) ( 'should not invalidate when code is invalid' , async ( ) => {
38
39
editFile ( 'App.jsx' , ( code ) =>
39
40
code . replace ( '<div className="App">' , '<div className="App"}>' ) ,
40
41
)
41
42
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' )
46
46
// if import.meta.invalidate happened, the old page won't be shown because the page is reloaded
47
47
expect ( await page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
48
48
@@ -90,7 +90,7 @@ if (!isBuild) {
90
90
'Parent rendered' ,
91
91
] ,
92
92
)
93
- await untilUpdated ( ( ) => page . textContent ( '#parent' ) , 'Updated' )
93
+ await expect . poll ( ( ) => page . textContent ( '#parent' ) ) . toMatch ( 'Updated' )
94
94
} )
95
95
96
96
// #3301
@@ -122,10 +122,9 @@ if (!isBuild) {
122
122
'Parent rendered' ,
123
123
] ,
124
124
)
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' )
129
128
} )
130
129
131
130
test ( 'should hmr files with "react/jsx-runtime"' , async ( ) => {
@@ -143,10 +142,9 @@ if (!isBuild) {
143
142
) ,
144
143
[ '[vite] hot updated: /hmr/jsx-import-runtime.js' ] ,
145
144
)
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' )
150
148
151
149
expect ( await page . textContent ( '#state-button' ) ) . toMatch ( 'count is: 1' )
152
150
} )
0 commit comments