diff --git a/aio/package.json b/aio/package.json index 2036c0ca9c..e3a3bfad0f 100644 --- a/aio/package.json +++ b/aio/package.json @@ -10,7 +10,7 @@ "start": "yarn check-env && ng serve", "build": "yarn check-env && yarn setup && ng build -prod -sm", "lint": "yarn check-env && yarn docs-lint && ng lint", - "test": "yarn check-env && ng test --sourcemap=false", + "test": "yarn check-env && ng test", "pree2e": "yarn ~~update-webdriver", "e2e": "yarn check-env && ng e2e --no-webdriver-update", "setup": "yarn && yarn boilerplate:add && yarn docs && yarn generate-plunkers && yarn generate-zips", diff --git a/aio/src/test-specs.ts b/aio/src/test-specs.ts new file mode 100644 index 0000000000..296d19078a --- /dev/null +++ b/aio/src/test-specs.ts @@ -0,0 +1,4 @@ +// Find all the tests. +const context = (require).context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); diff --git a/aio/src/test.ts b/aio/src/test.ts index 9bf72267e9..722acc0395 100644 --- a/aio/src/test.ts +++ b/aio/src/test.ts @@ -1,5 +1,6 @@ // This file is required by karma.conf.js and loads recursively all the .spec and framework files +// Test dependencies. import 'zone.js/dist/long-stack-trace-zone'; import 'zone.js/dist/proxy.js'; import 'zone.js/dist/sync-test'; @@ -12,9 +13,25 @@ import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; +// List vendors here to increase test rebuild performance. +import '@angular/common'; +import '@angular/common/testing'; +import '@angular/core/'; +import '@angular/core/testing'; +import '@angular/platform-browser'; +import '@angular/platform-browser/testing'; +import '@angular/platform-browser/animations'; +import '@angular/platform-browser-dynamic'; +import '@angular/platform-browser-dynamic/testing'; +import '@angular/http'; +import '@angular/http/testing'; +import '@angular/animations'; +import '@angular/material'; +import '@angular/service-worker'; +import 'rxjs'; // tslint:disable-line + // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare var __karma__: any; -declare var require: any; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; @@ -24,9 +41,9 @@ getTestBed().initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ); + +declare var System: any; // Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); -// Finally, start Karma to run the tests. -__karma__.start(); +System.import('./test-specs.ts') + // Finally, start Karma to run the tests. + .then(() => __karma__.start()); diff --git a/aio/src/tsconfig.app.json b/aio/src/tsconfig.app.json index 752114294d..ed04bb91fd 100644 --- a/aio/src/tsconfig.app.json +++ b/aio/src/tsconfig.app.json @@ -9,6 +9,7 @@ "exclude": [ "testing/**/*", "test.ts", + "test-specs.ts", "**/*.spec.ts" ] }