mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore(): add missing paths for karma config
This commit is contained in:
+20
-10
@@ -4,18 +4,28 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
|
||||
|
||||
__karma__.loaded = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* Gets map of module alias to location or package.
|
||||
* @param dir Directory name under `src/` for create a map for.
|
||||
*/
|
||||
function getPathsMap(dir) {
|
||||
return Object.keys(window.__karma__.files)
|
||||
.filter(isComponentsFile)
|
||||
.reduce(function(pathsMapping, appPath) {
|
||||
var pathToReplace = new RegExp('^/base/dist/' + dir + '/');
|
||||
var moduleName = appPath.replace(pathToReplace, './').replace(/\.js$/, '');
|
||||
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath];
|
||||
return pathsMapping;
|
||||
}, {});
|
||||
}
|
||||
|
||||
System.config({
|
||||
packages: {
|
||||
'base/dist/app': {
|
||||
'base/dist/components': {
|
||||
defaultExtension: false,
|
||||
format: 'register',
|
||||
map: Object.keys(window.__karma__.files)
|
||||
.filter(onlyAppFiles)
|
||||
.reduce(function(pathsMapping, appPath) {
|
||||
var moduleName = appPath.replace(/^\/base\/dist\/app\//, './').replace(/\.js$/, '');
|
||||
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]
|
||||
return pathsMapping;
|
||||
}, {})
|
||||
map: getPathsMap('components')
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -36,8 +46,8 @@ System.import('angular2/platform/browser').then(function(browser_adapter) {
|
||||
__karma__.error(error.stack || error);
|
||||
});
|
||||
|
||||
function onlyAppFiles(filePath) {
|
||||
return /^\/base\/dist\/app\/(?!spec)([a-z0-9-_\/]+)\.js$/.test(filePath);
|
||||
function isComponentsFile(filePath) {
|
||||
return /^\/base\/dist\/components\/(?!spec)([a-z0-9-_\/]+)\.js$/.test(filePath);
|
||||
}
|
||||
|
||||
function onlySpecFiles(path) {
|
||||
|
||||
+9
-2
@@ -2,10 +2,16 @@ module.exports = function(config) {
|
||||
config.set({
|
||||
basePath: '',
|
||||
frameworks: ['jasmine'],
|
||||
plugins: [
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher')
|
||||
],
|
||||
files: [
|
||||
{pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true},
|
||||
{pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
|
||||
{pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true},
|
||||
{pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
|
||||
{pattern: 'node_modules/angular2/bundles/testing.js', included: true, watched: true},
|
||||
{pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true},
|
||||
|
||||
{pattern: 'karma-test-shim.js', included: true, watched: true},
|
||||
|
||||
@@ -23,7 +29,8 @@ module.exports = function(config) {
|
||||
],
|
||||
proxies: {
|
||||
// required for component assests fetched by Angular's compiler
|
||||
"/app/": "/base/dist/demo-app/"
|
||||
"/demo-app/": "/base/dist/demo-app/",
|
||||
"/components/": "/base/dist/components/",
|
||||
},
|
||||
exclude: [],
|
||||
preprocessors: {},
|
||||
|
||||
Reference in New Issue
Block a user