@@ -19,10 +19,34 @@ test('should update', async () => {
19
19
} )
20
20
21
21
test ( 'should hmr' , async ( ) => {
22
- editFile ( 'App.jsx' , ( code ) => code . replace ( 'Vite + React' , 'Updated' ) )
23
- await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Updated' )
22
+ editFile ( 'App.jsx' , ( code ) =>
23
+ code . replace ( 'Vite + React' , 'Vite + React Updated' ) ,
24
+ )
25
+ await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React Updated' )
24
26
// preserve state
25
27
expect ( await page . textContent ( '#state-button' ) ) . toMatch ( 'count is: 1' )
28
+
29
+ editFile ( 'App.jsx' , ( code ) =>
30
+ code . replace ( 'Vite + React Updated' , 'Vite + React' ) ,
31
+ )
32
+ await untilUpdated ( ( ) => page . textContent ( 'h1' ) , 'Hello Vite + React' )
33
+ } )
34
+
35
+ test . runIf ( isServe ) ( 'should not invalidate when code is invalid' , async ( ) => {
36
+ editFile ( 'App.jsx' , ( code ) =>
37
+ code . replace ( '<div className="App">' , '<div className="App"}>' ) ,
38
+ )
39
+
40
+ await untilUpdated (
41
+ ( ) => page . textContent ( 'vite-error-overlay .message-body' ) ,
42
+ 'Unexpected token' ,
43
+ )
44
+ // if import.meta.invalidate happened, the old page won't be shown because the page is reloaded
45
+ expect ( await page . textContent ( 'h1' ) ) . toMatch ( 'Hello Vite + React' )
46
+
47
+ editFile ( 'App.jsx' , ( code ) =>
48
+ code . replace ( '<div className="App"}>' , '<div className="App">' ) ,
49
+ )
26
50
} )
27
51
28
52
test . runIf ( isServe ) (
@@ -59,7 +83,6 @@ if (!isBuild) {
59
83
'[vite] hot updated: /hmr/parent.jsx' ,
60
84
'Parent rendered' ,
61
85
] ,
62
- true ,
63
86
)
64
87
await untilUpdated ( ( ) => page . textContent ( '#parent' ) , 'Updated' )
65
88
} )
@@ -86,7 +109,6 @@ if (!isBuild) {
86
109
'[vite] hot updated: /context/ContextButton.jsx' ,
87
110
'Parent rendered' ,
88
111
] ,
89
- true ,
90
112
)
91
113
await untilUpdated (
92
114
( ) => page . textContent ( '#context-provider' ) ,
0 commit comments