@@ -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,9 @@ 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 (
192+ ...getTestRunnerDependencies ( options . testRunner === 'vitest' , ! ! options . skipInstall ) ,
193+ ) ;
246194 }
247195
248196 return chain ( rules ) ;
@@ -392,17 +340,15 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
392340 test :
393341 options . skipTests || options . minimal
394342 ? 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- } ,
343+ : {
344+ builder : Builders . BuildUnitTest ,
345+ options :
346+ options . testRunner === 'vitest'
347+ ? { }
348+ : {
349+ runner : 'karma' ,
350+ } ,
351+ } ,
406352 } ,
407353 } ;
408354
0 commit comments