@@ -99,7 +99,7 @@ describe(`app-dir-hmr`, () => {
99
99
'window.__TEST_NO_RELOAD === undefined'
100
100
)
101
101
// Used to be flaky but presumably no longer is.
102
- // If this flakes again, please add the received value as a commnet .
102
+ // If this flakes again, please add the received value as a comment .
103
103
expect ( { envValue, mpa } ) . toEqual ( {
104
104
envValue : 'ipad' ,
105
105
mpa : false ,
@@ -245,5 +245,73 @@ describe(`app-dir-hmr`, () => {
245
245
it ( 'should have no unexpected action error for hmr' , async ( ) => {
246
246
expect ( next . cliOutput ) . not . toContain ( 'Unexpected action' )
247
247
} )
248
+
249
+ it ( 'can navigate cleanly to a page that requires a change in the Webpack runtime' , async ( ) => {
250
+ // This isn't a very accurate test since the Webpack runtime is somewhat an implementation detail.
251
+ // To ensure this is still valid, check the `*/webpack.*.hot-update.js` network response content when the navigation is triggered.
252
+ // If there is new functionality added, the test is still valid.
253
+ // If not, the test doesn't cover anything new.
254
+ // TODO: Enforce console.error assertions or MPA navigation assertions in all tests instead.
255
+ const browser = await next . browser ( '/bundler-runtime-changes' )
256
+ await browser . eval ( 'window.__TEST_NO_RELOAD = true' )
257
+
258
+ await browser
259
+ . elementByCss ( 'a' )
260
+ . click ( )
261
+ . waitForElementByCss ( '[data-testid="new-runtime-functionality-page"]' )
262
+
263
+ const logs = await browser . log ( )
264
+ // TODO: Should assert on all logs but these are cluttered with logs from our test utils (e.g. playwright tracing or webdriver)
265
+ if ( process . env . TURBOPACK ) {
266
+ // FIXME: logging "rebuilding" multiple times instead of closing it of with "done in"
267
+ // Should just not branch here and have the same logs as Webpack.
268
+ expect ( logs ) . toEqual (
269
+ expect . arrayContaining ( [
270
+ {
271
+ message : '[Fast Refresh] rebuilding' ,
272
+ source : 'log' ,
273
+ } ,
274
+ {
275
+ message : '[Fast Refresh] rebuilding' ,
276
+ source : 'log' ,
277
+ } ,
278
+ {
279
+ message : '[Fast Refresh] rebuilding' ,
280
+ source : 'log' ,
281
+ } ,
282
+ ] )
283
+ )
284
+ expect ( logs ) . not . toEqual (
285
+ expect . arrayContaining ( [
286
+ {
287
+ message : expect . stringContaining ( '[Fast Refresh] done in' ) ,
288
+ source : 'log' ,
289
+ } ,
290
+ ] )
291
+ )
292
+ } else {
293
+ expect ( logs ) . toEqual (
294
+ expect . arrayContaining ( [
295
+ {
296
+ message : '[Fast Refresh] rebuilding' ,
297
+ source : 'log' ,
298
+ } ,
299
+ {
300
+ message : expect . stringContaining ( '[Fast Refresh] done in' ) ,
301
+ source : 'log' ,
302
+ } ,
303
+ ] )
304
+ )
305
+ expect ( logs ) . not . toEqual (
306
+ expect . arrayContaining ( [
307
+ expect . objectContaining ( {
308
+ source : 'error' ,
309
+ } ) ,
310
+ ] )
311
+ )
312
+ }
313
+ // No MPA navigation triggered
314
+ expect ( await browser . eval ( 'window.__TEST_NO_RELOAD' ) ) . toEqual ( true )
315
+ } )
248
316
} )
249
317
} )
0 commit comments