@@ -153,8 +153,35 @@ if (!isBuild) {
153153 await untilUpdated ( ( ) => el . textContent ( ) , '3' )
154154 } )
155155
156- if ( ! process . env . VITE_TEST_FULL_BUNDLE_MODE ) {
157- test ( 'invalidate' , async ( ) => {
156+ test ( 'invalidate' , async ( ) => {
157+ const el = await page . $ ( '.invalidation-parent' )
158+ await untilBrowserLogAfter (
159+ ( ) =>
160+ editFile ( 'invalidation/child.js' , ( code ) =>
161+ code . replace ( 'child' , 'child updated' ) ,
162+ ) ,
163+ [
164+ '>>> vite:beforeUpdate -- update' ,
165+ '>>> vite:invalidate -- /invalidation/child.js' ,
166+ '[vite] invalidate /invalidation/child.js' ,
167+ '[vite] hot updated: /invalidation/child.js' ,
168+ '>>> vite:afterUpdate -- update' ,
169+ '>>> vite:beforeUpdate -- update' ,
170+ '(invalidation) parent is executing' ,
171+ '[vite] hot updated: /invalidation/parent.js' ,
172+ '>>> vite:afterUpdate -- update' ,
173+ ] ,
174+ true ,
175+ )
176+ await untilUpdated ( ( ) => el . textContent ( ) , 'child updated' )
177+ } )
178+
179+ test ( 'invalidate works with multiple tabs' , async ( ) => {
180+ let page2 : Page
181+ try {
182+ page2 = await browser . newPage ( )
183+ await page2 . goto ( viteTestUrl )
184+
158185 const el = await page . $ ( '.invalidation-parent' )
159186 await untilBrowserLogAfter (
160187 ( ) =>
@@ -167,6 +194,7 @@ if (!isBuild) {
167194 '[vite] invalidate /invalidation/child.js' ,
168195 '[vite] hot updated: /invalidation/child.js' ,
169196 '>>> vite:afterUpdate -- update' ,
197+ // if invalidate dedupe doesn't work correctly, this beforeUpdate will be called twice
170198 '>>> vite:beforeUpdate -- update' ,
171199 '(invalidation) parent is executing' ,
172200 '[vite] hot updated: /invalidation/parent.js' ,
@@ -175,51 +203,21 @@ if (!isBuild) {
175203 true ,
176204 )
177205 await untilUpdated ( ( ) => el . textContent ( ) , 'child updated' )
178- } )
179-
180- test ( 'invalidate works with multiple tabs' , async ( ) => {
181- let page2 : Page
182- try {
183- page2 = await browser . newPage ( )
184- await page2 . goto ( viteTestUrl )
185-
186- const el = await page . $ ( '.invalidation-parent' )
187- await untilBrowserLogAfter (
188- ( ) =>
189- editFile ( 'invalidation/child.js' , ( code ) =>
190- code . replace ( 'child' , 'child updated' ) ,
191- ) ,
192- [
193- '>>> vite:beforeUpdate -- update' ,
194- '>>> vite:invalidate -- /invalidation/child.js' ,
195- '[vite] invalidate /invalidation/child.js' ,
196- '[vite] hot updated: /invalidation/child.js' ,
197- '>>> vite:afterUpdate -- update' ,
198- // if invalidate dedupe doesn't work correctly, this beforeUpdate will be called twice
199- '>>> vite:beforeUpdate -- update' ,
200- '(invalidation) parent is executing' ,
201- '[vite] hot updated: /invalidation/parent.js' ,
202- '>>> vite:afterUpdate -- update' ,
203- ] ,
204- true ,
205- )
206- await untilUpdated ( ( ) => el . textContent ( ) , 'child updated' )
207- } finally {
208- await page2 . close ( )
209- }
210- } )
206+ } finally {
207+ await page2 . close ( )
208+ }
209+ } )
211210
212- test ( 'invalidate on root triggers page reload' , async ( ) => {
213- editFile ( 'invalidation/root.js' , ( code ) =>
214- code . replace ( 'Init' , 'Updated' ) ,
215- )
216- await page . waitForEvent ( 'load' )
217- await untilUpdated (
218- async ( ) => ( await page . $ ( '.invalidation-root' ) ) . textContent ( ) ,
219- 'Updated' ,
220- )
221- } )
211+ test ( 'invalidate on root triggers page reload' , async ( ) => {
212+ editFile ( 'invalidation/root.js' , ( code ) => code . replace ( 'Init' , 'Updated' ) )
213+ await page . waitForEvent ( 'load' )
214+ await untilUpdated (
215+ async ( ) => ( await page . $ ( '.invalidation-root' ) ) . textContent ( ) ,
216+ 'Updated' ,
217+ )
218+ } )
222219
220+ if ( ! process . env . VITE_TEST_FULL_BUNDLE_MODE ) {
223221 test ( 'soft invalidate' , async ( ) => {
224222 const el = await page . $ ( '.soft-invalidation' )
225223 expect ( await el . textContent ( ) ) . toBe (
0 commit comments