@@ -150,6 +150,39 @@ describe('Migration from Karma to Vitest unit-test builder', () => {
150150 ] ) ;
151151 } ) ;
152152
153+ it ( 'should keep explicit base Karma build defaults in per configuration testing configurations' , async ( ) => {
154+ const { projects } = tree . readJson ( '/angular.json' ) as any ;
155+ projects . app . targets . test . options . styles = [ 'src/test-styles.scss' ] ;
156+ projects . app . targets . test . options . aot = true ;
157+ projects . app . targets . test . configurations = {
158+ ci : {
159+ watch : false ,
160+ } ,
161+ } ;
162+ tree . overwrite ( '/angular.json' , JSON . stringify ( { version : 1 , projects } ) ) ;
163+
164+ const newTree = await schematicRunner . runSchematic ( 'migrate-karma-to-vitest' , { } , tree ) ;
165+ const { projects : newProjects } = newTree . readJson ( '/angular.json' ) as any ;
166+
167+ expect ( newProjects . app . targets . build . configurations . testing . aot ) . toBeTrue ( ) ;
168+ expect ( newProjects . app . targets . build . configurations [ 'testing-ci' ] . aot ) . toBeTrue ( ) ;
169+ } ) ;
170+
171+ it ( 'should apply Karma build defaults to testing configurations without base test options' , async ( ) => {
172+ const { projects } = tree . readJson ( '/angular.json' ) as any ;
173+ projects . app . targets . test . configurations = {
174+ ci : projects . app . targets . test . options ,
175+ } ;
176+ delete projects . app . targets . test . options ;
177+ tree . overwrite ( '/angular.json' , JSON . stringify ( { version : 1 , projects } ) ) ;
178+
179+ const newTree = await schematicRunner . runSchematic ( 'migrate-karma-to-vitest' , { } , tree ) ;
180+ const { projects : newProjects } = newTree . readJson ( '/angular.json' ) as any ;
181+
182+ expect ( newProjects . app . targets . test . configurations . ci . buildTarget ) . toBe ( ':build:testing-ci' ) ;
183+ expect ( newProjects . app . targets . build . configurations [ 'testing-ci' ] . aot ) . toBeFalse ( ) ;
184+ } ) ;
185+
153186 it ( 'should omit testing configuration if options match base build options' , async ( ) => {
154187 const { projects } = tree . readJson ( '/angular.json' ) as any ;
155188 projects . app . targets . build . options . aot = false ;
0 commit comments