@@ -124,6 +124,13 @@ describe('Migration to v6', () => {
124124 return JSON . parse ( tree . readContent ( configPath ) ) ;
125125 }
126126
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+
127134 describe ( 'file creation/deletion' , ( ) => {
128135 it ( 'should delete the old config file' , ( ) => {
129136 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
@@ -474,7 +481,7 @@ describe('Migration to v6', () => {
474481 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
475482 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
476483 const config = getConfig ( tree ) ;
477- expect ( config . targets ) . not . toBeDefined ( ) ;
484+ expect ( config . architect ) . not . toBeDefined ( ) ;
478485 } ) ;
479486 } ) ;
480487
@@ -526,7 +533,7 @@ describe('Migration to v6', () => {
526533 it ( 'should set build target' , ( ) => {
527534 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
528535 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
529- const build = getConfig ( tree ) . projects . foo . targets . build ;
536+ const build = getTarget ( tree , ' build' ) ;
530537 expect ( build . builder ) . toEqual ( '@angular-devkit/build-angular:browser' ) ;
531538 expect ( build . options . scripts ) . toEqual ( [ ] ) ;
532539 expect ( build . options . styles ) . toEqual ( [ 'src/styles.css' ] ) ;
@@ -560,7 +567,7 @@ describe('Migration to v6', () => {
560567 it ( 'should not set baseHref on build & serve targets if not defined' , ( ) => {
561568 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
562569 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
563- const build = getConfig ( tree ) . projects . foo . targets . build ;
570+ const build = getTarget ( tree , ' build' ) ;
564571 expect ( build . options . baseHref ) . toBeUndefined ( ) ;
565572 } ) ;
566573
@@ -569,27 +576,25 @@ describe('Migration to v6', () => {
569576 config . apps [ 0 ] . baseHref = '/base/href/' ;
570577 tree . create ( oldConfigPath , JSON . stringify ( config , null , 2 ) ) ;
571578 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
572- const build = getConfig ( tree ) . projects . foo . targets . build ;
579+ const build = getTarget ( tree , ' build' ) ;
573580 expect ( build . options . baseHref ) . toEqual ( '/base/href/' ) ;
574581 } ) ;
575582
576583 it ( 'should add serviceWorker to production configuration' , ( ) => {
577584 baseConfig . apps [ 0 ] . serviceWorker = true ;
578585 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
579586 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 ) ;
585590 } ) ;
586591
587592 it ( 'should add production configuration when no environments' , ( ) => {
588593 delete baseConfig . apps [ 0 ] . environments ;
589594 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
590595 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 ( {
593598 production : {
594599 optimization : true ,
595600 outputHashing : 'all' ,
@@ -608,8 +613,8 @@ describe('Migration to v6', () => {
608613 tree . delete ( '/src/environments/environment.prod.ts' ) ;
609614 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
610615 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 ( {
613618 prod : {
614619 fileReplacements : [ {
615620 replace : 'src/environments/environment.ts' ,
@@ -633,7 +638,7 @@ describe('Migration to v6', () => {
633638 it ( 'should set the serve target' , ( ) => {
634639 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
635640 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
636- const serve = getConfig ( tree ) . projects . foo . targets . serve ;
641+ const serve = getTarget ( tree , ' serve' ) ;
637642 expect ( serve . builder ) . toEqual ( '@angular-devkit/build-angular:dev-server' ) ;
638643 expect ( serve . options ) . toEqual ( {
639644 browserTarget : 'foo:build' ,
@@ -646,7 +651,7 @@ describe('Migration to v6', () => {
646651 it ( 'should set the test target' , ( ) => {
647652 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
648653 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
649- const test = getConfig ( tree ) . projects . foo . targets [ 'test' ] ;
654+ const test = getTarget ( tree , 'test' ) ;
650655 expect ( test . builder ) . toEqual ( '@angular-devkit/build-angular:karma' ) ;
651656 expect ( test . options . main ) . toEqual ( 'src/test.ts' ) ;
652657 expect ( test . options . polyfills ) . toEqual ( 'src/polyfills.ts' ) ;
@@ -665,7 +670,7 @@ describe('Migration to v6', () => {
665670 it ( 'should set the extract i18n target' , ( ) => {
666671 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
667672 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
668- const extract = getConfig ( tree ) . projects . foo . targets [ 'extract-i18n' ] ;
673+ const extract = getTarget ( tree , 'extract-i18n' ) ;
669674 expect ( extract . builder ) . toEqual ( '@angular-devkit/build-angular:extract-i18n' ) ;
670675 expect ( extract . options ) . toBeDefined ( ) ;
671676 expect ( extract . options . browserTarget ) . toEqual ( `foo:build` ) ;
@@ -674,7 +679,7 @@ describe('Migration to v6', () => {
674679 it ( 'should set the lint target' , ( ) => {
675680 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
676681 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
677- const tslint = getConfig ( tree ) . projects . foo . targets [ 'lint' ] ;
682+ const tslint = getTarget ( tree , 'lint' ) ;
678683 expect ( tslint . builder ) . toEqual ( '@angular-devkit/build-angular:tslint' ) ;
679684 expect ( tslint . options ) . toBeDefined ( ) ;
680685 expect ( tslint . options . tsConfig )
@@ -691,8 +696,8 @@ describe('Migration to v6', () => {
691696
692697 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
693698 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 ;
696701 expect ( budgets . length ) . toEqual ( 1 ) ;
697702 expect ( budgets [ 0 ] . type ) . toEqual ( 'bundle' ) ;
698703 expect ( budgets [ 0 ] . name ) . toEqual ( 'main' ) ;
@@ -707,7 +712,7 @@ describe('Migration to v6', () => {
707712 const e2eProject = getConfig ( tree ) . projects [ 'foo-e2e' ] ;
708713 expect ( e2eProject . root ) . toBe ( 'e2e' ) ;
709714 expect ( e2eProject . sourceRoot ) . toBe ( 'e2e' ) ;
710- const e2eOptions = e2eProject . targets . e2e ;
715+ const e2eOptions = e2eProject . architect . e2e ;
711716 expect ( e2eOptions . builder ) . toEqual ( '@angular-devkit/build-angular:protractor' ) ;
712717 const options = e2eOptions . options ;
713718 expect ( options . protractorConfig ) . toEqual ( './protractor.conf.js' ) ;
@@ -721,7 +726,7 @@ describe('Migration to v6', () => {
721726 const e2eProject = getConfig ( tree ) . projects [ 'foo-e2e' ] ;
722727 expect ( e2eProject . root ) . toBe ( 'apps/app1/e2e' ) ;
723728 expect ( e2eProject . sourceRoot ) . toBe ( 'apps/app1/e2e' ) ;
724- const e2eOptions = e2eProject . targets . e2e ;
729+ const e2eOptions = e2eProject . architect . e2e ;
725730 expect ( e2eOptions . builder ) . toEqual ( '@angular-devkit/build-angular:protractor' ) ;
726731 const options = e2eOptions . options ;
727732 expect ( options . protractorConfig ) . toEqual ( './protractor.conf.js' ) ;
@@ -731,7 +736,7 @@ describe('Migration to v6', () => {
731736 it ( 'should set the lint target' , ( ) => {
732737 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
733738 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 ;
735740 expect ( tslint . builder ) . toEqual ( '@angular-devkit/build-angular:tslint' ) ;
736741 expect ( tslint . options ) . toBeDefined ( ) ;
737742 expect ( tslint . options . tsConfig ) . toEqual ( [ 'e2e/tsconfig.e2e.json' ] ) ;
@@ -988,7 +993,7 @@ describe('Migration to v6', () => {
988993 tree . create ( oldConfigPath , JSON . stringify ( baseConfig , null , 2 ) ) ;
989994 tree = schematicRunner . runSchematic ( 'migration-01' , defaultOptions , tree ) ;
990995 const config = getConfig ( tree ) ;
991- const target = config . projects . foo . targets . server ;
996+ const target = config . projects . foo . architect . server ;
992997 expect ( target ) . toBeDefined ( ) ;
993998 expect ( target . builder ) . toEqual ( '@angular-devkit/build-angular:server' ) ;
994999 expect ( target . options . outputPath ) . toEqual ( 'dist/server' ) ;
0 commit comments