@@ -55,8 +55,6 @@ describe(`app-dir-hmr`, () => {
5555 } )
5656
5757 it ( 'should update server components after navigating to a page with a different runtime' , async ( ) => {
58- const envContent = await next . readFile ( envFile )
59-
6058 const browser = await next . browser ( '/env/node' )
6159 await browser . loadPage ( `${ next . url } /env/edge` )
6260 await browser . eval ( 'window.__TEST_NO_RELOAD = true' )
@@ -134,12 +132,15 @@ describe(`app-dir-hmr`, () => {
134132 ] )
135133 }
136134 } finally {
137- await next . patchFile ( envFile , envContent )
135+ // TOOD: use sandbox instead
136+ await next . patchFile ( envFile , 'MY_DEVICE="mac"' )
137+ await retry ( async ( ) => {
138+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
139+ } )
138140 }
139141 } )
140142
141143 it ( 'should update server components pages when env files is changed (nodejs)' , async ( ) => {
142- const envContent = await next . readFile ( envFile )
143144 const browser = await next . browser ( '/env/node' )
144145 expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
145146 await next . patchFile ( envFile , 'MY_DEVICE="ipad"' )
@@ -182,12 +183,15 @@ describe(`app-dir-hmr`, () => {
182183 )
183184 }
184185 } finally {
185- await next . patchFile ( envFile , envContent )
186+ // TOOD: use sandbox instead
187+ await next . patchFile ( envFile , 'MY_DEVICE="mac"' )
188+ await retry ( async ( ) => {
189+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
190+ } )
186191 }
187192 } )
188193
189194 it ( 'should update server components pages when env files is changed (edge)' , async ( ) => {
190- const envContent = await next . readFile ( envFile )
191195 const browser = await next . browser ( '/env/edge' )
192196 expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
193197 await next . patchFile ( envFile , 'MY_DEVICE="ipad"' )
@@ -230,7 +234,11 @@ describe(`app-dir-hmr`, () => {
230234 )
231235 }
232236 } finally {
233- await next . patchFile ( envFile , envContent )
237+ // TOOD: use sandbox instead
238+ await next . patchFile ( envFile , 'MY_DEVICE="mac"' )
239+ await retry ( async ( ) => {
240+ expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
241+ } )
234242 }
235243 } )
236244
0 commit comments