From 7493435911535284302f4ec3fc178cd1e1cad992 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 14 Apr 2018 10:31:24 -0700 Subject: [PATCH] test(aio): move reflect-metadata polyfills to test.ts (#23234) This resolves https://github.com/angular/angular-cli/issues/10333 and nicely cleans up the code. PR Close #23234 --- aio/src/environments/environment.ts | 10 ++++------ aio/src/polyfills.ts | 3 --- aio/src/test.ts | 4 ++++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/aio/src/environments/environment.ts b/aio/src/environments/environment.ts index 77d62f0968..2fdfcb911b 100644 --- a/aio/src/environments/environment.ts +++ b/aio/src/environments/environment.ts @@ -4,12 +4,10 @@ // The list of which env maps to which file can be found in `angular-cli.json`. -// Reflect.metadata polyfill is only needed in the JIT/dev mode. -// -// In order to load these polyfills early enough (before app code), polyfill.ts imports this file to -// to change the order in the final bundle. -import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; +// Reflect.metadata polyfill is only needed in the JIT, which use use only for tests +// to make the unit tests work we load these polyfills in tests.ts instead +// import 'core-js/es6/reflect'; +// import 'core-js/es7/reflect'; export const environment = { diff --git a/aio/src/polyfills.ts b/aio/src/polyfills.ts index 67309e5514..babba81e97 100644 --- a/aio/src/polyfills.ts +++ b/aio/src/polyfills.ts @@ -27,9 +27,6 @@ * and executed before the rest of the application files are executed. */ -/** HACK: force import of environment.ts/environment.prod.ts to load env specific polyfills */ -import './environments/environment'; - /** ALL Firefox browsers require the following to support `@angular/animation`. **/ // import 'web-animations-js'; // Run `npm install --save web-animations-js`. diff --git a/aio/src/test.ts b/aio/src/test.ts index 1c2f3fced5..09b54c7389 100644 --- a/aio/src/test.ts +++ b/aio/src/test.ts @@ -9,6 +9,10 @@ import { declare const require: any; +// Reflect.metadata polyfill is only needed in the JIT mode which we use only for unit tests +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule,