@@ -23,6 +23,7 @@ import {
2323 url ,
2424} from '@angular-devkit/schematics' ;
2525import { Schema as ComponentOptions , Style as ComponentStyle } from '../component/schema' ;
26+ import { getTestRunnerDependencies } from '../utility/dependencies' ;
2627import {
2728 DependencyType ,
2829 ExistingBehavior ,
@@ -187,62 +188,7 @@ function addDependenciesToPackageJson(options: ApplicationOptions): Rule {
187188 }
188189
189190 if ( ! options . skipTests ) {
190- if ( options . testRunner === 'vitest' ) {
191- rules . push (
192- addDependency ( 'vitest' , latestVersions [ 'vitest' ] , {
193- type : DependencyType . Dev ,
194- existing : ExistingBehavior . Skip ,
195- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
196- } ) ,
197- addDependency ( 'jsdom' , latestVersions [ 'jsdom' ] , {
198- type : DependencyType . Dev ,
199- existing : ExistingBehavior . Skip ,
200- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
201- } ) ,
202- ) ;
203- } else {
204- rules . push (
205- addDependency ( 'karma' , latestVersions [ 'karma' ] , {
206- type : DependencyType . Dev ,
207- existing : ExistingBehavior . Skip ,
208- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
209- } ) ,
210- addDependency ( 'karma-chrome-launcher' , latestVersions [ 'karma-chrome-launcher' ] , {
211- type : DependencyType . Dev ,
212- existing : ExistingBehavior . Skip ,
213- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
214- } ) ,
215- addDependency ( 'karma-coverage' , latestVersions [ 'karma-coverage' ] , {
216- type : DependencyType . Dev ,
217- existing : ExistingBehavior . Skip ,
218- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
219- } ) ,
220- addDependency ( 'karma-jasmine' , latestVersions [ 'karma-jasmine' ] , {
221- type : DependencyType . Dev ,
222- existing : ExistingBehavior . Skip ,
223- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
224- } ) ,
225- addDependency (
226- 'karma-jasmine-html-reporter' ,
227- latestVersions [ 'karma-jasmine-html-reporter' ] ,
228- {
229- type : DependencyType . Dev ,
230- existing : ExistingBehavior . Skip ,
231- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
232- } ,
233- ) ,
234- addDependency ( 'jasmine-core' , latestVersions [ 'jasmine-core' ] , {
235- type : DependencyType . Dev ,
236- existing : ExistingBehavior . Skip ,
237- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
238- } ) ,
239- addDependency ( '@types/jasmine' , latestVersions [ '@types/jasmine' ] , {
240- type : DependencyType . Dev ,
241- existing : ExistingBehavior . Skip ,
242- install : options . skipInstall ? InstallBehavior . None : InstallBehavior . Auto ,
243- } ) ,
244- ) ;
245- }
191+ rules . push ( ...getTestRunnerDependencies ( options . testRunner , ! ! options . skipInstall ) ) ;
246192 }
247193
248194 return chain ( rules ) ;
@@ -392,17 +338,15 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
392338 test :
393339 options . skipTests || options . minimal
394340 ? undefined
395- : options . testRunner === 'vitest'
396- ? {
397- builder : Builders . BuildUnitTest ,
398- options : { } ,
399- }
400- : {
401- builder : Builders . BuildUnitTest ,
402- options : {
403- runner : 'karma' ,
404- } ,
405- } ,
341+ : {
342+ builder : Builders . BuildUnitTest ,
343+ options :
344+ options . testRunner === 'vitest'
345+ ? { }
346+ : {
347+ runner : 'karma' ,
348+ } ,
349+ } ,
406350 } ,
407351 } ;
408352
0 commit comments