UNPKG

1.34 kBJavaScriptView Raw
1/*global mocha, __karma__, window*/
2Error.stackTraceLimit = Infinity;
3jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
4
5__karma__.loaded = function () { };
6window.expect = chai.expect;
7
8var basePath = '/base/';
9
10function isJsFile(path) {
11 return endsWith(path, '.js');
12}
13
14function isSpecFile(path) {
15 return endsWith(path, '.tests.js');
16}
17
18function endsWith(path, ending) {
19 return path.slice(-ending.length) == ending;
20}
21
22var allSpecFiles = Object.keys(window.__karma__.files)
23 .filter(isSpecFile);
24
25// Load our SystemJS configuration.
26System.config({
27 baseURL: basePath
28});
29
30System.import('system.config.js').then(function () {
31 // Load and configure the TestComponentBuilder.
32 return Promise.all([
33 System.import('@angular/core/testing'),
34 System.import('@angular/platform-browser-dynamic/testing')
35 ]).then(function (providers) {
36 var testing = providers[0];
37 var testingBrowser = providers[1];
38
39 testing.TestBed.initTestEnvironment(testingBrowser.BrowserDynamicTestingModule
40 , testingBrowser.platformBrowserDynamicTesting());
41 });
42}).then(function () {
43 // Finally, load all spec files.
44 // This will run the tests directly.
45 return Promise.all(
46 allSpecFiles.map(function (moduleName) {
47 return System.import(moduleName);
48 }));
49}).then(__karma__.start, __karma__.error);