@@ -28,7 +28,7 @@ describe("userConfig", () => {
2828 {
2929 [ convertToNativePaths ( currentDir ) ] : { } ,
3030 } ,
31- currentDir
31+ currentDir ,
3232 ) ;
3333 const entry = await asyncGeneratorToArray ( traverseFolder ( "/" ) ) ;
3434 expect ( entry ) . toEqual ( [ ] ) ;
@@ -129,7 +129,7 @@ describe("userConfig", () => {
129129 {
130130 [ convertToNativePaths ( currentDir ) ] : { } ,
131131 } ,
132- currentDir
132+ currentDir ,
133133 ) ;
134134 const file = await findSWAConfigFile ( "/" ) ;
135135 expect ( file ) . toBe ( null ) ;
@@ -159,7 +159,7 @@ describe("userConfig", () => {
159159 expect ( config ) . toBeNull ( ) ;
160160 expect ( logger . warn ) . toHaveBeenLastCalledWith (
161161 ` WARNING: Functionality defined in the routes.json file is now deprecated. File will be ignored!\n` +
162- ` Read more: https://docs.microsoft.com/azure/static-web-apps/configuration#routes`
162+ ` Read more: https://docs.microsoft.com/azure/static-web-apps/configuration#routes` ,
163163 ) ;
164164 } ) ;
165165
@@ -178,10 +178,29 @@ describe("userConfig", () => {
178178 expect ( config ) . toBeNull ( ) ;
179179 expect ( logger . warn ) . toHaveBeenLastCalledWith (
180180 ` WARNING: Functionality defined in the routes.json file is now deprecated. File will be ignored!\n` +
181- ` Read more: https://docs.microsoft.com/azure/static-web-apps/configuration#routes`
181+ ` Read more: https://docs.microsoft.com/azure/static-web-apps/configuration#routes` ,
182182 ) ;
183183 } ) ;
184184
185+ it ( "should warn with KB unit when config file exceeds max size" , async ( ) => {
186+ // Create a valid config file larger than 20KB (SWA_RUNTIME_CONFIG_MAX_SIZE_IN_KB)
187+ // Use many routes to inflate file size while keeping schema valid
188+ const routes = [ ] ;
189+ for ( let i = 0 ; i < 500 ; i ++ ) {
190+ routes . push ( { route : `/route-${ i } -${ "a" . repeat ( 30 ) } ` , rewrite : `/index-${ i } .html` } ) ;
191+ }
192+ const largeContent = JSON . stringify ( { routes } ) ;
193+ vol . fromJSON ( {
194+ "staticwebapp.config.json" : largeContent ,
195+ } ) ;
196+
197+ vi . spyOn ( logger , "log" ) . mockImplementation ( ( ) => { } ) ;
198+
199+ await findSWAConfigFile ( "/" ) ;
200+ expect ( logger . warn ) . toHaveBeenCalledWith ( expect . stringContaining ( "KB" ) ) ;
201+ expect ( logger . warn ) . not . toHaveBeenCalledWith ( expect . stringContaining ( "bytes" ) ) ;
202+ } ) ;
203+
185204 it ( "should ignore routes.json if a staticwebapp.config.json exists" , async ( ) => {
186205 vol . fromNestedJSON ( {
187206 s : {
0 commit comments