docs(testing): update testing setup to use systemjs.config.js
This commit is contained in:
parent
650a4d17e8
commit
4b104d7cc9
|
@ -22,72 +22,33 @@ var allSpecFiles = Object.keys(window.__karma__.files)
|
||||||
.filter(isSpecFile)
|
.filter(isSpecFile)
|
||||||
.filter(isBuiltFile);
|
.filter(isBuiltFile);
|
||||||
|
|
||||||
//////////////////////////
|
System.config({
|
||||||
// Load our SystemJS configuration.
|
baseURL: '/base',
|
||||||
|
packageWithIndex: true // sadly, we can't use umd packages (yet?)
|
||||||
// map tells the System loader where to look for things
|
|
||||||
var map = {
|
|
||||||
'app': 'app',
|
|
||||||
|
|
||||||
'@angular': 'node_modules/@angular',
|
|
||||||
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
|
|
||||||
'rxjs': 'node_modules/rxjs'
|
|
||||||
};
|
|
||||||
|
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
|
||||||
var packages = {
|
|
||||||
'app': { main: 'main.js', defaultExtension: 'js' },
|
|
||||||
'rxjs': { defaultExtension: 'js' },
|
|
||||||
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
|
||||||
};
|
|
||||||
|
|
||||||
var ngPackageNames = [
|
|
||||||
'common',
|
|
||||||
'compiler',
|
|
||||||
'core',
|
|
||||||
'http',
|
|
||||||
'platform-browser',
|
|
||||||
'platform-browser-dynamic',
|
|
||||||
'router',
|
|
||||||
'router-deprecated',
|
|
||||||
'upgrade',
|
|
||||||
];
|
|
||||||
|
|
||||||
// Add package entries for angular packages
|
|
||||||
ngPackageNames.forEach(function(pkgName) {
|
|
||||||
|
|
||||||
// Bundled (~40 requests): DOESN'T WORK IN KARMA OR WALLABY (YET?)
|
|
||||||
//packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
|
|
||||||
|
|
||||||
// Individual files (~300 requests):
|
|
||||||
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var config = {
|
System.import('systemjs.config.js')
|
||||||
baseURL: '/base',
|
.then(function () {
|
||||||
map: map,
|
return Promise.all([
|
||||||
packages: packages
|
System.import('@angular/core/testing'),
|
||||||
}
|
System.import('@angular/platform-browser-dynamic/testing')
|
||||||
|
])
|
||||||
|
})
|
||||||
|
.then(function (providers) {
|
||||||
|
var testing = providers[0];
|
||||||
|
var testingBrowser = providers[1];
|
||||||
|
|
||||||
System.config(config);
|
testing.setBaseTestProviders(
|
||||||
//////////////
|
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
||||||
|
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
||||||
|
|
||||||
Promise.all([
|
})
|
||||||
System.import('@angular/core/testing'),
|
.then(function() {
|
||||||
System.import('@angular/platform-browser-dynamic/testing')
|
// Finally, load all spec files.
|
||||||
]).then(function (providers) {
|
// This will run the tests directly.
|
||||||
var testing = providers[0];
|
return Promise.all(
|
||||||
var testingBrowser = providers[1];
|
allSpecFiles.map(function (moduleName) {
|
||||||
|
return System.import(moduleName);
|
||||||
testing.setBaseTestProviders(
|
}));
|
||||||
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
})
|
||||||
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
.then(__karma__.start, __karma__.error);
|
||||||
|
|
||||||
}).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);
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ module.exports = function(config) {
|
||||||
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
|
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
|
||||||
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
|
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
|
||||||
|
|
||||||
|
{pattern: 'systemjs.config.js', included: false, watched: false},
|
||||||
'karma-test-shim.js',
|
'karma-test-shim.js',
|
||||||
|
|
||||||
// transpiled application & spec code paths loaded via module imports
|
// transpiled application & spec code paths loaded via module imports
|
||||||
|
|
|
@ -32,15 +32,20 @@
|
||||||
'upgrade',
|
'upgrade',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add package entries for angular packages
|
// Individual files (~300 requests):
|
||||||
ngPackageNames.forEach(function(pkgName) {
|
function packIndex(pkgName) {
|
||||||
|
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
|
||||||
|
}
|
||||||
|
|
||||||
// Bundled (~40 requests):
|
// Bundled (~40 requests):
|
||||||
|
function packUmd(pkgName) {
|
||||||
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
|
packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
|
||||||
|
};
|
||||||
|
|
||||||
// Individual files (~300 requests):
|
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
|
||||||
//packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
|
|
||||||
});
|
// Add package entries for angular packages
|
||||||
|
ngPackageNames.forEach(setPackageConfig);
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
map: map,
|
map: map,
|
||||||
|
|
|
@ -9,10 +9,5 @@
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"suppressImplicitAnyIndexErrors": true
|
"suppressImplicitAnyIndexErrors": true
|
||||||
},
|
}
|
||||||
"exclude": [
|
|
||||||
"node_modules",
|
|
||||||
"typings/main",
|
|
||||||
"typings/main.d.ts"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = function () {
|
||||||
files: [
|
files: [
|
||||||
// System.js for module loading
|
// System.js for module loading
|
||||||
{pattern: 'node_modules/systemjs/dist/system.js', instrument: false},
|
{pattern: 'node_modules/systemjs/dist/system.js', instrument: false},
|
||||||
|
{pattern: 'systemjs.config.js', instrument: false},
|
||||||
|
|
||||||
// Polyfills
|
// Polyfills
|
||||||
{pattern: 'node_modules/core-js/client/shim.min.js', instrument: false},
|
{pattern: 'node_modules/core-js/client/shim.min.js', instrument: false},
|
||||||
|
@ -38,86 +39,39 @@ module.exports = function () {
|
||||||
|
|
||||||
bootstrap: function (wallaby) {
|
bootstrap: function (wallaby) {
|
||||||
wallaby.delayStart();
|
wallaby.delayStart();
|
||||||
systemConfig();
|
|
||||||
|
|
||||||
Promise.all([
|
System.config({
|
||||||
System.import('@angular/core/testing'),
|
packageWithIndex: true // sadly, we can't use umd packages (yet?)
|
||||||
System.import('@angular/platform-browser-dynamic/testing')
|
|
||||||
])
|
|
||||||
.then(function (providers) {
|
|
||||||
var testing = providers[0];
|
|
||||||
var testingBrowser = providers[1];
|
|
||||||
|
|
||||||
testing.setBaseTestProviders(
|
|
||||||
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
|
||||||
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
|
||||||
|
|
||||||
|
|
||||||
// Load all spec files
|
|
||||||
return Promise.all(wallaby.tests.map(function (specFile) {
|
|
||||||
return System.import(specFile);
|
|
||||||
}));
|
|
||||||
})
|
|
||||||
.then(function () {
|
|
||||||
wallaby.start();
|
|
||||||
})
|
|
||||||
.catch(function (e) {
|
|
||||||
setTimeout(function () {
|
|
||||||
throw e;
|
|
||||||
}, 0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//////////////////////////
|
System.import('systemjs.config.js')
|
||||||
// SystemJS configuration.
|
.then(function () {
|
||||||
function systemConfig() {
|
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];
|
||||||
|
|
||||||
// map tells the System loader where to look for things
|
testing.setBaseTestProviders(
|
||||||
var map = {
|
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
||||||
'app': 'app',
|
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
||||||
|
|
||||||
'@angular': 'node_modules/@angular',
|
// Load all spec files
|
||||||
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
|
return Promise.all(wallaby.tests.map(function (specFile) {
|
||||||
'rxjs': 'node_modules/rxjs'
|
return System.import(specFile);
|
||||||
};
|
}));
|
||||||
|
})
|
||||||
// packages tells the System loader how to load when no filename and/or no extension
|
.then(function () {
|
||||||
var packages = {
|
wallaby.start();
|
||||||
'app': { main: 'main.js', defaultExtension: 'js' },
|
})
|
||||||
'rxjs': { defaultExtension: 'js' },
|
.catch(function (e) {
|
||||||
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
|
setTimeout(function () {
|
||||||
};
|
throw e;
|
||||||
|
}, 0);
|
||||||
var ngPackageNames = [
|
|
||||||
'common',
|
|
||||||
'compiler',
|
|
||||||
'core',
|
|
||||||
'http',
|
|
||||||
'platform-browser',
|
|
||||||
'platform-browser-dynamic',
|
|
||||||
'router',
|
|
||||||
'router-deprecated',
|
|
||||||
'upgrade',
|
|
||||||
];
|
|
||||||
|
|
||||||
// Add package entries for angular packages
|
|
||||||
ngPackageNames.forEach(function(pkgName) {
|
|
||||||
|
|
||||||
// Bundled (~40 requests): DOESN'T WORK IN WALLABY OR KARMA (YET?)
|
|
||||||
// packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
|
|
||||||
|
|
||||||
// Individual files (~300 requests):
|
|
||||||
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var config = {
|
|
||||||
map: map,
|
|
||||||
packages: packages
|
|
||||||
}
|
|
||||||
|
|
||||||
System.config(config);
|
|
||||||
}
|
|
||||||
//////////////////
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue