@@ -124,6 +124,13 @@ describe('Migration to v6', () => {
124
124
return JSON . parse ( tree . readContent ( configPath ) ) ;
125
125
}
126
126
127
+ // tslint:disable-next-line:no-any
128
+ function getTarget ( tree : UnitTestTree , targetName : string ) : any {
129
+ const project = getConfig ( tree ) . projects . foo ;
130
+
131
+ return project . architect [ targetName ] ;
132
+ }
133
+
127
134
describe ( 'file creation/deletion' , ( ) => {
128
135
it ( 'should delete the old config file' , ( ) => {
129
136
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
@@ -474,7 +481,7 @@ describe('Migration to v6', () => {
474
481
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
475
482
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
476
483
const config = getConfig ( tree ) ;
477
- expect ( config . targets ) . not . toBeDefined ( ) ;
484
+ expect ( config . architect ) . not . toBeDefined ( ) ;
478
485
} ) ;
479
486
} ) ;
480
487
@@ -526,7 +533,7 @@ describe('Migration to v6', () => {
526
533
it ( 'should set build target' , ( ) => {
527
534
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
528
535
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
529
- const build = getConfig ( tree ) . projects . foo . targets . build ;
536
+ const build = getTarget ( tree , ' build' ) ;
530
537
expect ( build . builder ) . toEqual ( '@angular-devkit/build-angular:browser' ) ;
531
538
expect ( build . options . scripts ) . toEqual ( [ ] ) ;
532
539
expect ( build . options . styles ) . toEqual ( [ 'src/styles.css' ] ) ;
@@ -560,7 +567,7 @@ describe('Migration to v6', () => {
560
567
it ( 'should not set baseHref on build & serve targets if not defined' , ( ) => {
561
568
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
562
569
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
563
- const build = getConfig ( tree ) . projects . foo . targets . build ;
570
+ const build = getTarget ( tree , ' build' ) ;
564
571
expect ( build . options . baseHref ) . toBeUndefined ( ) ;
565
572
} ) ;
566
573
@@ -569,27 +576,25 @@ describe('Migration to v6', () => {
569
576
config . apps [ 0 ] . baseHref = '/base/href/' ;
570
577
tree . create ( oldConfigPath , JSON . stringify ( config , null , 2 ) ) ;
571
578
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
572
- const build = getConfig ( tree ) . projects . foo . targets . build ;
579
+ const build = getTarget ( tree , ' build' ) ;
573
580
expect ( build . options . baseHref ) . toEqual ( '/base/href/' ) ;
574
581
} ) ;
575
582
576
583
it ( 'should add serviceWorker to production configuration' , ( ) => {
577
584
baseConfig . apps [ 0 ] . serviceWorker = true ;
578
585
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
579
586
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
580
- const config = getConfig ( tree ) ;
581
- expect ( config . projects . foo . targets . build . options . serviceWorker ) . toBeUndefined ( ) ;
582
- expect (
583
- config . projects . foo . targets . build . configurations . production . serviceWorker ,
584
- ) . toBe ( true ) ;
587
+ const build = getTarget ( tree , 'build' ) ;
588
+ expect ( build . options . serviceWorker ) . toBeUndefined ( ) ;
589
+ expect ( build . configurations . production . serviceWorker ) . toBe ( true ) ;
585
590
} ) ;
586
591
587
592
it ( 'should add production configuration when no environments' , ( ) => {
588
593
delete baseConfig . apps [ 0 ] . environments ;
589
594
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
590
595
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
591
- const config = getConfig ( tree ) ;
592
- expect ( config . projects . foo . targets . build . configurations ) . toEqual ( {
596
+ const build = getTarget ( tree , 'build' ) ;
597
+ expect ( build . configurations ) . toEqual ( {
593
598
production : {
594
599
optimization : true ,
595
600
outputHashing : 'all' ,
@@ -608,8 +613,8 @@ describe('Migration to v6', () => {
608
613
tree . delete ( '/src/environments/environment.prod.ts' ) ;
609
614
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
610
615
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
611
- const config = getConfig ( tree ) ;
612
- expect ( config . projects . foo . targets . build . configurations ) . toEqual ( {
616
+ const build = getTarget ( tree , 'build' ) ;
617
+ expect ( build . configurations ) . toEqual ( {
613
618
prod : {
614
619
fileReplacements : [ {
615
620
replace : 'src/environments/environment.ts' ,
@@ -633,7 +638,7 @@ describe('Migration to v6', () => {
633
638
it ( 'should set the serve target' , ( ) => {
634
639
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
635
640
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
636
- const serve = getConfig ( tree ) . projects . foo . targets . serve ;
641
+ const serve = getTarget ( tree , ' serve' ) ;
637
642
expect ( serve . builder ) . toEqual ( '@angular-devkit/build-angular:dev-server' ) ;
638
643
expect ( serve . options ) . toEqual ( {
639
644
browserTarget : 'foo:build' ,
@@ -646,7 +651,7 @@ describe('Migration to v6', () => {
646
651
it ( 'should set the test target' , ( ) => {
647
652
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
648
653
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
649
- const test = getConfig ( tree ) . projects . foo . targets [ 'test' ] ;
654
+ const test = getTarget ( tree , 'test' ) ;
650
655
expect ( test . builder ) . toEqual ( '@angular-devkit/build-angular:karma' ) ;
651
656
expect ( test . options . main ) . toEqual ( 'src/test.ts' ) ;
652
657
expect ( test . options . polyfills ) . toEqual ( 'src/polyfills.ts' ) ;
@@ -665,7 +670,7 @@ describe('Migration to v6', () => {
665
670
it ( 'should set the extract i18n target' , ( ) => {
666
671
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
667
672
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
668
- const extract = getConfig ( tree ) . projects . foo . targets [ 'extract-i18n' ] ;
673
+ const extract = getTarget ( tree , 'extract-i18n' ) ;
669
674
expect ( extract . builder ) . toEqual ( '@angular-devkit/build-angular:extract-i18n' ) ;
670
675
expect ( extract . options ) . toBeDefined ( ) ;
671
676
expect ( extract . options . browserTarget ) . toEqual ( `foo:build` ) ;
@@ -674,7 +679,7 @@ describe('Migration to v6', () => {
674
679
it ( 'should set the lint target' , ( ) => {
675
680
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
676
681
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
677
- const tslint = getConfig ( tree ) . projects . foo . targets [ 'lint' ] ;
682
+ const tslint = getTarget ( tree , 'lint' ) ;
678
683
expect ( tslint . builder ) . toEqual ( '@angular-devkit/build-angular:tslint' ) ;
679
684
expect ( tslint . options ) . toBeDefined ( ) ;
680
685
expect ( tslint . options . tsConfig )
@@ -691,8 +696,8 @@ describe('Migration to v6', () => {
691
696
692
697
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
693
698
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
694
- const config = getConfig ( tree ) ;
695
- const budgets = config . projects . foo . targets . build . configurations . production . budgets ;
699
+ const build = getTarget ( tree , 'build' ) ;
700
+ const budgets = build . configurations . production . budgets ;
696
701
expect ( budgets . length ) . toEqual ( 1 ) ;
697
702
expect ( budgets [ 0 ] . type ) . toEqual ( 'bundle' ) ;
698
703
expect ( budgets [ 0 ] . name ) . toEqual ( 'main' ) ;
@@ -707,7 +712,7 @@ describe('Migration to v6', () => {
707
712
const e2eProject = getConfig ( tree ) . projects [ 'foo-e2e' ] ;
708
713
expect ( e2eProject . root ) . toBe ( 'e2e' ) ;
709
714
expect ( e2eProject . sourceRoot ) . toBe ( 'e2e' ) ;
710
- const e2eOptions = e2eProject . targets . e2e ;
715
+ const e2eOptions = e2eProject . architect . e2e ;
711
716
expect ( e2eOptions . builder ) . toEqual ( '@angular-devkit/build-angular:protractor' ) ;
712
717
const options = e2eOptions . options ;
713
718
expect ( options . protractorConfig ) . toEqual ( './protractor.conf.js' ) ;
@@ -721,7 +726,7 @@ describe('Migration to v6', () => {
721
726
const e2eProject = getConfig ( tree ) . projects [ 'foo-e2e' ] ;
722
727
expect ( e2eProject . root ) . toBe ( 'apps/app1/e2e' ) ;
723
728
expect ( e2eProject . sourceRoot ) . toBe ( 'apps/app1/e2e' ) ;
724
- const e2eOptions = e2eProject . targets . e2e ;
729
+ const e2eOptions = e2eProject . architect . e2e ;
725
730
expect ( e2eOptions . builder ) . toEqual ( '@angular-devkit/build-angular:protractor' ) ;
726
731
const options = e2eOptions . options ;
727
732
expect ( options . protractorConfig ) . toEqual ( './protractor.conf.js' ) ;
@@ -731,7 +736,7 @@ describe('Migration to v6', () => {
731
736
it ( 'should set the lint target' , ( ) => {
732
737
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
733
738
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
734
- const tslint = getConfig ( tree ) . projects [ 'foo-e2e' ] . targets . lint ;
739
+ const tslint = getConfig ( tree ) . projects [ 'foo-e2e' ] . architect . lint ;
735
740
expect ( tslint . builder ) . toEqual ( '@angular-devkit/build-angular:tslint' ) ;
736
741
expect ( tslint . options ) . toBeDefined ( ) ;
737
742
expect ( tslint . options . tsConfig ) . toEqual ( [ 'e2e/tsconfig.e2e.json' ] ) ;
@@ -988,7 +993,7 @@ describe('Migration to v6', () => {
988
993
tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
989
994
tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
990
995
const config = getConfig ( tree ) ;
991
- const target = config . projects . foo . targets . server ;
996
+ const target = config . projects . foo . architect . server ;
992
997
expect ( target ) . toBeDefined ( ) ;
993
998
expect ( target . builder ) . toEqual ( '@angular-devkit/build-angular:server' ) ;
994
999
expect ( target . options . outputPath ) . toEqual ( 'dist/server' ) ;
0 commit comments