@@ -23,11 +23,10 @@ const imagesDir = join(appDir, '.next', 'cache', 'images')
2323const nextConfig = new File ( join ( appDir , 'next.config.js' ) )
2424const largeSize = 1080 // defaults defined in server/config.ts
2525let nextOutput
26- let buildOutput
2726let appPort
2827let app
29- const sharpRuntimeWarning = `For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended`
30- const sharpBuildWarning = 'Detected `next/image` usage without `sharp`.'
28+
29+ const sharpMissingText = `For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended`
3130
3231async function fsToJson ( dir , output = { } ) {
3332 const files = await fs . readdir ( dir )
@@ -727,29 +726,13 @@ function runTests({ w, isDev, domains = [], ttl, isSharp }) {
727726 expect ( Object . keys ( json1 ) . length ) . toBe ( 1 )
728727 } )
729728
730- if ( isDev ) {
731- it ( 'should not have runtime warning in dev' , ( ) => {
732- expect ( nextOutput ) . not . toContain ( sharpRuntimeWarning )
733- } )
734-
735- it ( 'should not have build warning in dev' , ( ) => {
736- expect ( buildOutput ) . not . toContain ( sharpBuildWarning )
737- } )
738- } else if ( isSharp ) {
739- it ( 'should not have runtime warning when sharp is installed' , ( ) => {
740- expect ( nextOutput ) . not . toContain ( sharpRuntimeWarning )
741- } )
742-
743- it ( 'should not have build warning when sharp is installed' , ( ) => {
744- expect ( buildOutput ) . not . toContain ( sharpBuildWarning )
729+ if ( isDev || isSharp ) {
730+ it ( 'should not have sharp missing warning' , ( ) => {
731+ expect ( nextOutput ) . not . toContain ( sharpMissingText )
745732 } )
746733 } else {
747- it ( 'should have runtime warning when sharp is not installed' , ( ) => {
748- expect ( nextOutput ) . toContain ( sharpRuntimeWarning )
749- } )
750-
751- it ( 'should have build warning when sharp is not installed' , ( ) => {
752- expect ( buildOutput ) . toContain ( sharpBuildWarning )
734+ it ( 'should have sharp missing warning' , ( ) => {
735+ expect ( nextOutput ) . toContain ( sharpMissingText )
753736 } )
754737 }
755738}
@@ -927,10 +910,8 @@ describe('Image Optimizer', () => {
927910 } ,
928911 } )
929912 nextOutput = ''
930- buildOutput = ''
931913 nextConfig . replace ( '{ /* replaceme */ }' , json )
932- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
933- buildOutput = out . stderr
914+ await nextBuild ( appDir )
934915 appPort = await findPort ( )
935916 app = await nextStart ( appDir , appPort , {
936917 onStderr ( msg ) {
@@ -968,8 +949,7 @@ describe('Image Optimizer', () => {
968949 },
969950 }`
970951 )
971- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
972- buildOutput = out . stderr
952+ await nextBuild ( appDir )
973953 appPort = await findPort ( )
974954 app = await nextStart ( appDir , appPort )
975955 } )
@@ -1045,8 +1025,7 @@ describe('Image Optimizer', () => {
10451025 },
10461026 }`
10471027 nextConfig . replace ( '{ /* replaceme */ }' , newConfig )
1048- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1049- buildOutput = out . stderr
1028+ await nextBuild ( appDir )
10501029 appPort = await findPort ( )
10511030 app = await nextStart ( appDir , appPort )
10521031 } )
@@ -1105,7 +1084,6 @@ describe('Image Optimizer', () => {
11051084 const size = 384 // defaults defined in server/config.ts
11061085 beforeAll ( async ( ) => {
11071086 nextOutput = ''
1108- buildOutput = ''
11091087 appPort = await findPort ( )
11101088 app = await launchApp ( appDir , appPort , {
11111089 onStderr ( msg ) {
@@ -1133,7 +1111,6 @@ describe('Image Optimizer', () => {
11331111 } ,
11341112 } )
11351113 nextOutput = ''
1136- buildOutput = ''
11371114 nextConfig . replace ( '{ /* replaceme */ }' , json )
11381115 appPort = await findPort ( )
11391116 app = await launchApp ( appDir , appPort , {
@@ -1156,9 +1133,7 @@ describe('Image Optimizer', () => {
11561133 const size = 384 // defaults defined in server/config.ts
11571134 beforeAll ( async ( ) => {
11581135 nextOutput = ''
1159- buildOutput = ''
1160- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1161- buildOutput = out . stderr
1136+ await nextBuild ( appDir )
11621137 appPort = await findPort ( )
11631138 app = await nextStart ( appDir , appPort , {
11641139 onStderr ( msg ) {
@@ -1192,10 +1167,8 @@ describe('Image Optimizer', () => {
11921167 } ,
11931168 } )
11941169 nextOutput = ''
1195- buildOutput = ''
11961170 nextConfig . replace ( '{ /* replaceme */ }' , json )
1197- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1198- buildOutput = out . stderr
1171+ await nextBuild ( appDir )
11991172 appPort = await findPort ( )
12001173 app = await nextStart ( appDir , appPort , {
12011174 onStderr ( msg ) {
0 commit comments