@@ -55,8 +55,6 @@ describe(`app-dir-hmr`, () => {
55
55
} )
56
56
57
57
it ( 'should update server components after navigating to a page with a different runtime' , async ( ) => {
58
- const envContent = await next . readFile ( envFile )
59
-
60
58
const browser = await next . browser ( '/env/node' )
61
59
await browser . loadPage ( `${ next . url } /env/edge` )
62
60
await browser . eval ( 'window.__TEST_NO_RELOAD = true' )
@@ -134,12 +132,15 @@ describe(`app-dir-hmr`, () => {
134
132
] )
135
133
}
136
134
} 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
+ } )
138
140
}
139
141
} )
140
142
141
143
it ( 'should update server components pages when env files is changed (nodejs)' , async ( ) => {
142
- const envContent = await next . readFile ( envFile )
143
144
const browser = await next . browser ( '/env/node' )
144
145
expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
145
146
await next . patchFile ( envFile , 'MY_DEVICE="ipad"' )
@@ -182,12 +183,15 @@ describe(`app-dir-hmr`, () => {
182
183
)
183
184
}
184
185
} 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
+ } )
186
191
}
187
192
} )
188
193
189
194
it ( 'should update server components pages when env files is changed (edge)' , async ( ) => {
190
- const envContent = await next . readFile ( envFile )
191
195
const browser = await next . browser ( '/env/edge' )
192
196
expect ( await browser . elementByCss ( 'p' ) . text ( ) ) . toBe ( 'mac' )
193
197
await next . patchFile ( envFile , 'MY_DEVICE="ipad"' )
@@ -230,7 +234,11 @@ describe(`app-dir-hmr`, () => {
230
234
)
231
235
}
232
236
} 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
+ } )
234
242
}
235
243
} )
236
244
0 commit comments