@@ -23,11 +23,10 @@ const imagesDir = join(appDir, '.next', 'cache', 'images')
23
23
const nextConfig = new File ( join ( appDir , 'next.config.js' ) )
24
24
const largeSize = 1080 // defaults defined in server/config.ts
25
25
let nextOutput
26
- let buildOutput
27
26
let appPort
28
27
let 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`
31
30
32
31
async function fsToJson ( dir , output = { } ) {
33
32
const files = await fs . readdir ( dir )
@@ -727,29 +726,13 @@ function runTests({ w, isDev, domains = [], ttl, isSharp }) {
727
726
expect ( Object . keys ( json1 ) . length ) . toBe ( 1 )
728
727
} )
729
728
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 )
745
732
} )
746
733
} 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 )
753
736
} )
754
737
}
755
738
}
@@ -927,10 +910,8 @@ describe('Image Optimizer', () => {
927
910
} ,
928
911
} )
929
912
nextOutput = ''
930
- buildOutput = ''
931
913
nextConfig . replace ( '{ /* replaceme */ }' , json )
932
- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
933
- buildOutput = out . stderr
914
+ await nextBuild ( appDir )
934
915
appPort = await findPort ( )
935
916
app = await nextStart ( appDir , appPort , {
936
917
onStderr ( msg ) {
@@ -968,8 +949,7 @@ describe('Image Optimizer', () => {
968
949
},
969
950
}`
970
951
)
971
- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
972
- buildOutput = out . stderr
952
+ await nextBuild ( appDir )
973
953
appPort = await findPort ( )
974
954
app = await nextStart ( appDir , appPort )
975
955
} )
@@ -1045,8 +1025,7 @@ describe('Image Optimizer', () => {
1045
1025
},
1046
1026
}`
1047
1027
nextConfig . replace ( '{ /* replaceme */ }' , newConfig )
1048
- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1049
- buildOutput = out . stderr
1028
+ await nextBuild ( appDir )
1050
1029
appPort = await findPort ( )
1051
1030
app = await nextStart ( appDir , appPort )
1052
1031
} )
@@ -1105,7 +1084,6 @@ describe('Image Optimizer', () => {
1105
1084
const size = 384 // defaults defined in server/config.ts
1106
1085
beforeAll ( async ( ) => {
1107
1086
nextOutput = ''
1108
- buildOutput = ''
1109
1087
appPort = await findPort ( )
1110
1088
app = await launchApp ( appDir , appPort , {
1111
1089
onStderr ( msg ) {
@@ -1133,7 +1111,6 @@ describe('Image Optimizer', () => {
1133
1111
} ,
1134
1112
} )
1135
1113
nextOutput = ''
1136
- buildOutput = ''
1137
1114
nextConfig . replace ( '{ /* replaceme */ }' , json )
1138
1115
appPort = await findPort ( )
1139
1116
app = await launchApp ( appDir , appPort , {
@@ -1156,9 +1133,7 @@ describe('Image Optimizer', () => {
1156
1133
const size = 384 // defaults defined in server/config.ts
1157
1134
beforeAll ( async ( ) => {
1158
1135
nextOutput = ''
1159
- buildOutput = ''
1160
- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1161
- buildOutput = out . stderr
1136
+ await nextBuild ( appDir )
1162
1137
appPort = await findPort ( )
1163
1138
app = await nextStart ( appDir , appPort , {
1164
1139
onStderr ( msg ) {
@@ -1192,10 +1167,8 @@ describe('Image Optimizer', () => {
1192
1167
} ,
1193
1168
} )
1194
1169
nextOutput = ''
1195
- buildOutput = ''
1196
1170
nextConfig . replace ( '{ /* replaceme */ }' , json )
1197
- const out = await nextBuild ( appDir , [ ] , { stderr : true } )
1198
- buildOutput = out . stderr
1171
+ await nextBuild ( appDir )
1199
1172
appPort = await findPort ( )
1200
1173
app = await nextStart ( appDir , appPort , {
1201
1174
onStderr ( msg ) {
0 commit comments