@@ -19,10 +19,34 @@ test('should update', async () => {
1919} )
2020
2121test ( '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' )
2426 // preserve state
2527 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+ )
2650} )
2751
2852test . runIf ( isServe ) (
@@ -59,7 +83,6 @@ if (!isBuild) {
5983 '[vite] hot updated: /hmr/parent.jsx' ,
6084 'Parent rendered' ,
6185 ] ,
62- true ,
6386 )
6487 await untilUpdated ( ( ) => page . textContent ( '#parent' ) , 'Updated' )
6588 } )
@@ -86,7 +109,6 @@ if (!isBuild) {
86109 '[vite] hot updated: /context/ContextButton.jsx' ,
87110 'Parent rendered' ,
88111 ] ,
89- true ,
90112 )
91113 await untilUpdated (
92114 ( ) => page . textContent ( '#context-provider' ) ,
0 commit comments