This contains major changes to the compiler, bootstrap of the platforms and test environment initialization. Main part of #10043 Closes #10164 BREAKING CHANGE: - Semantics and name of `@AppModule` (now `@NgModule`) changed quite a bit. This is actually not breaking as `@AppModules` were not part of rc.4. We will have detailed docs on `@NgModule` separately. - `coreLoadAndBootstrap` and `coreBootstrap` can't be used any more (without migration support). Use `bootstrapModule` / `bootstrapModuleFactory` instead. - All Components listed in routes have to be part of the `declarations` of an NgModule. Either directly on the bootstrap module / lazy loaded module, or in an NgModule imported by them.
86 lines
2.0 KiB
JavaScript
86 lines
2.0 KiB
JavaScript
/*global jasmine, __karma__, window*/
|
|
Error.stackTraceLimit = 5;
|
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
|
|
|
|
__karma__.loaded = function () {
|
|
};
|
|
|
|
function isJsFile(path) {
|
|
return path.slice(-3) == '.js';
|
|
}
|
|
|
|
function isSpecFile(path) {
|
|
return path.slice(-7) == 'spec.js';
|
|
}
|
|
|
|
function isBuiltFile(path) {
|
|
var builtPath = '/base/dist/';
|
|
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
|
|
}
|
|
|
|
var allSpecFiles = Object.keys(window.__karma__.files)
|
|
.filter(isSpecFile)
|
|
.filter(isBuiltFile);
|
|
|
|
// Load our SystemJS configuration.
|
|
System.config({
|
|
baseURL: '/base'
|
|
});
|
|
|
|
System.config(
|
|
{
|
|
map: {
|
|
'rxjs': 'node_modules/rxjs',
|
|
'@angular': 'dist/all/@angular'
|
|
},
|
|
packages: {
|
|
'@angular/core': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'@angular/compiler': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'@angular/common': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'@angular/platform-browser': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'@angular/platform-browser-dynamic': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'@angular/router': {
|
|
main: 'index.js',
|
|
defaultExtension: 'js'
|
|
},
|
|
'rxjs': {
|
|
main: 'Rx.js',
|
|
defaultExtension: 'js'
|
|
}
|
|
}
|
|
});
|
|
|
|
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];
|
|
|
|
testing.initTestEnvironment(
|
|
testingBrowser.BrowserDynamicTestingModule,
|
|
testingBrowser.browserDynamicTestingPlatform());
|
|
|
|
}).then(function() {
|
|
// Finally, load all spec files.
|
|
// This will run the tests directly.
|
|
return Promise.all(
|
|
allSpecFiles.map(function (moduleName) {
|
|
return System.import(moduleName);
|
|
}));
|
|
}).then(__karma__.start, __karma__.error); |