@@ -27,13 +27,20 @@ const compiledFilesPath = posix.join(
27
27
".next" ,
28
28
) ;
29
29
30
+ const requiredServerFilePath = posix . join ( compiledFilesPath , "required-server-files.json" ) ;
31
+
30
32
describe ( "next.config override" , ( ) => {
31
33
it ( "should have images optimization disabled" , async function ( ) {
32
- if ( scenario . includes ( "with-empty-config" ) ) {
34
+ if (
35
+ scenario . includes ( "with-empty-config" ) ||
36
+ scenario . includes ( "with-images-unoptimized-false" ) ||
37
+ scenario . includes ( "with-custom-image-loader" )
38
+ ) {
39
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
33
40
this . skip ( ) ;
34
41
}
35
42
36
- const serverFiles = await fsExtra . readJson ( ` ${ compiledFilesPath } /required-server-files.json` ) ;
43
+ const serverFiles = await fsExtra . readJson ( requiredServerFilePath ) ;
37
44
const config = serverFiles . config ;
38
45
39
46
// Verify that images.unoptimized is set to true
@@ -47,6 +54,7 @@ describe("next.config override", () => {
47
54
48
55
it ( "should preserve other user set next configs" , async function ( ) {
49
56
if ( scenario . includes ( "with-empty-config" ) ) {
57
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
50
58
this . skip ( ) ;
51
59
}
52
60
@@ -68,6 +76,7 @@ describe("next.config override", () => {
68
76
it ( "should handle function-style config correctly" , async function ( ) {
69
77
// Only run this test for scenarios with function-style config
70
78
if ( ! scenario . includes ( "function-style" ) ) {
79
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
71
80
this . skip ( ) ;
72
81
}
73
82
@@ -80,6 +89,7 @@ describe("next.config override", () => {
80
89
it ( "should handle object-style config correctly" , async function ( ) {
81
90
// Only run this test for scenarios with object-style config
82
91
if ( ! scenario . includes ( "object-style" ) && ! scenario . includes ( "with-empty-config" ) ) {
92
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
83
93
this . skip ( ) ;
84
94
}
85
95
@@ -92,4 +102,24 @@ describe("next.config override", () => {
92
102
assert . equal ( response . headers . get ( "x-config-type" ) ?? "" , "object" ) ;
93
103
}
94
104
} ) ;
105
+
106
+ it ( "should not override images.unoptimized if user explicitly defines configs" , async function ( ) {
107
+ if (
108
+ ! scenario . includes ( "with-images-unoptimized-false" ) &&
109
+ ! scenario . includes ( "with-custom-image-loader" )
110
+ ) {
111
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
112
+ this . skip ( ) ;
113
+ }
114
+
115
+ const serverFiles = await fsExtra . readJson ( requiredServerFilePath ) ;
116
+ const config = serverFiles . config ;
117
+
118
+ assert . ok ( config . images , "Config should have images property" ) ;
119
+ assert . strictEqual (
120
+ config . images . unoptimized ,
121
+ false ,
122
+ "Images should have unoptimized set to false" ,
123
+ ) ;
124
+ } ) ;
95
125
} ) ;
0 commit comments