@@ -877,83 +877,92 @@ describe.each([
877877 }
878878 } )
879879
880- it ( 'should recover after loader parse error in an imported file' , async ( ) => {
881- let browser
882- const aboutPage = join ( 'pages' , 'hmr' , 'about9.js' )
880+ // assertion is highly flakey in turbopack mode
881+ if ( ! process . env . TURBOPACK ) {
882+ it ( 'should recover after loader parse error in an imported file' , async ( ) => {
883+ let browser
884+ const aboutPage = join ( 'pages' , 'hmr' , 'about9.js' )
883885
884- const aboutContent = await next . readFile ( aboutPage )
885- try {
886- browser = await webdriver ( next . appPort , basePath + '/hmr/about9' )
887- await check ( ( ) => getBrowserBodyText ( browser ) , / T h i s i s t h e a b o u t p a g e / )
886+ const aboutContent = await next . readFile ( aboutPage )
887+ try {
888+ browser = await webdriver ( next . appPort , basePath + '/hmr/about9' )
889+ await check (
890+ ( ) => getBrowserBodyText ( browser ) ,
891+ / T h i s i s t h e a b o u t p a g e /
892+ )
888893
889- await next . patchFile (
890- aboutPage ,
891- aboutContent . replace (
892- 'export default' ,
893- 'import "../../components/parse-error.js"\nexport default'
894+ await next . patchFile (
895+ aboutPage ,
896+ aboutContent . replace (
897+ 'export default' ,
898+ 'import "../../components/parse-error.js"\nexport default'
899+ )
894900 )
895- )
896901
897- expect ( await hasRedbox ( browser ) ) . toBe ( true )
898- expect ( await getRedboxHeader ( browser ) ) . toMatch ( 'Failed to compile' )
899- let redboxSource = await getRedboxSource ( browser )
902+ expect ( await hasRedbox ( browser ) ) . toBe ( true )
903+ expect ( await getRedboxHeader ( browser ) ) . toMatch ( 'Failed to compile' )
904+ let redboxSource = await getRedboxSource ( browser )
905+
906+ redboxSource = redboxSource . replace ( `${ next . testDir } ` , '.' )
907+ if ( process . env . TURBOPACK ) {
908+ expect ( next . normalizeTestDirContent ( redboxSource ) )
909+ . toMatchInlineSnapshot ( `
910+ "./components/parse-error.js:3:1
911+ Parsing ecmascript source code failed
912+ 1 | This
913+ 2 | is
914+ > 3 | }}}
915+ | ^
916+ 4 | invalid
917+ 5 | js
918+
919+ Expression expected"
920+ ` )
921+ } else {
922+ redboxSource = redboxSource . substring (
923+ 0 ,
924+ redboxSource . indexOf ( '`----' )
925+ )
900926
901- redboxSource = redboxSource . replace ( ` ${ next . testDir } ` , '.' )
902- if ( process . env . TURBOPACK ) {
903- expect ( next . normalizeTestDirContent ( redboxSource ) )
904- . toMatchInlineSnapshot ( `
905- "./components/parse-error.js:3:1
906- Parsing ecmascript source code failed
927+ expect ( next . normalizeTestDirContent ( redboxSource ) )
928+ . toMatchInlineSnapshot ( `
929+ "./components/parse-error.js
930+ Error:
931+ x Expression expected
932+ ,-[./components/parse-error.js:1:1]
907933 1 | This
908934 2 | is
909- > 3 | }}}
910- | ^
935+ 3 | }}}
936+ : ^
911937 4 | invalid
912938 5 | js
939+ "
940+ ` )
941+ }
913942
914- Expression expected"
915- ` )
916- } else {
917- redboxSource = redboxSource . substring (
918- 0 ,
919- redboxSource . indexOf ( '`----' )
920- )
921-
922- expect ( next . normalizeTestDirContent ( redboxSource ) )
923- . toMatchInlineSnapshot ( `
924- "./components/parse-error.js
925- Error:
926- x Expression expected
927- ,-[./components/parse-error.js:1:1]
928- 1 | This
929- 2 | is
930- 3 | }}}
931- : ^
932- 4 | invalid
933- 5 | js
934- "
935- ` )
936- }
937-
938- await next . patchFile ( aboutPage , aboutContent )
939-
940- await check ( ( ) => getBrowserBodyText ( browser ) , / T h i s i s t h e a b o u t p a g e / )
941- expect ( await hasRedbox ( browser ) ) . toBe ( false )
942- } catch ( err ) {
943- await next . patchFile ( aboutPage , aboutContent )
943+ await next . patchFile ( aboutPage , aboutContent )
944944
945- if ( browser ) {
946945 await check (
947946 ( ) => getBrowserBodyText ( browser ) ,
948947 / T h i s i s t h e a b o u t p a g e /
949948 )
949+ expect ( await hasRedbox ( browser ) ) . toBe ( false )
950+ } catch ( err ) {
951+ await next . patchFile ( aboutPage , aboutContent )
952+
953+ if ( browser ) {
954+ await check (
955+ ( ) => getBrowserBodyText ( browser ) ,
956+ / T h i s i s t h e a b o u t p a g e /
957+ )
958+ }
959+ } finally {
960+ if ( browser ) {
961+ await browser . close ( )
962+ }
950963 }
951- } finally {
952- if ( browser ) {
953- await browser . close ( )
954- }
955- }
956- } )
964+ } )
965+ }
957966
958967 it ( 'should recover from errors in getInitialProps in client' , async ( ) => {
959968 let browser
0 commit comments