perf(aio): improve unit test rebuild time

This commit is contained in:
Filipe Silva 2017-04-21 20:20:02 +01:00 committed by Pete Bacon Darwin
parent 54e587a46d
commit d7719aa0f5
4 changed files with 29 additions and 7 deletions

View File

@ -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",

4
aio/src/test-specs.ts Normal file
View File

@ -0,0 +1,4 @@
// Find all the tests.
const context = (<any>require).context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

View File

@ -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());

View File

@ -9,6 +9,7 @@
"exclude": [
"testing/**/*",
"test.ts",
"test-specs.ts",
"**/*.spec.ts"
]
}