Files
angular__angular/test/karma-test-shim.js
T
Jeremy Elbourn 71229756a5 build: update packaging to match angular/angular (#3751)
* build: restructure release output

* build: inline metadata.json resources

* build: output re-export meatadata.json file in package root
2017-03-24 14:06:45 -07:00

50 lines
1.5 KiB
JavaScript

/*global jasmine, __karma__, window*/
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 3000;
__karma__.loaded = function () {};
var baseDir = '/base';
var configFile = baseDir + '/dist/packages/material/system-config-spec.js';
var specFiles = Object.keys(window.__karma__.files).filter(isMaterialSpecFile);
// Configure the base path for dist/
System.config({ baseURL: baseDir });
// Load the spec SystemJS configuration file.
System.import(configFile)
.then(configureTestBed)
.then(runMaterialSpecs)
.then(__karma__.start, __karma__.error);
/** Runs the Angular Material specs in Karma. */
function runMaterialSpecs() {
// By importing all spec files, Karma will run the tests directly.
return Promise.all(specFiles.map(function(fileName) {
return System.import(fileName);
}));
}
/** Whether the specified file is part of Angular Material. */
function isMaterialSpecFile(path) {
return path.slice(-8) === '.spec.js' && path.indexOf('node_modules') === -1;
}
/** Configures Angular's TestBed. */
function configureTestBed() {
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
testing.TestBed.initTestEnvironment(
testingBrowser.BrowserDynamicTestingModule,
testingBrowser.platformBrowserDynamicTesting()
);
});
}