I have some issue when I trying to test angular 2 with karma runner and got this error: http://ift.tt/24g8i74
I don't know what it this (got some errors when I update karma/node/grunt-karma). First got error with undefined character in headers (karma socket) after that about undefined forEach at _normalize.
I don't have any idea how I can fix it and where to looking. Maybe someone can help me?
My Karma.conf // Karma configuration
module.exports = function(config) {
config.set({
basePath: '.',
frameworks: ['jasmine'],
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-coverage',
],
colors: true,
autoWatch: true,
// don't shut down phantom instance for 1 minute
// because should be able to reuse the instance
// in one testrun. E.g. run unit tests against
// sources and minified artifacts
browserNoActivityTimeout: 60000,
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
logLevel: config.LOG_ERROR,
preprocessors: {
'built/production/**/!(*spec).js': ['coverage']
},
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.dev.js',
included: true,
watched: true
},
{
pattern: 'node_modules/angular2/bundles/http.dev.js',
included: true,
watched: true
},
{
pattern: 'node_modules/angular2/bundles/router.dev.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
}, {
pattern: 'src/**/*.ts',
included: false,
watched: false
}, {
pattern: 'built/production/**/*.js',
included: false,
watched: true
}, {
pattern: 'built/production/**/*.js.map',
included: false,
watched: false
}],
proxies: {
// required for component assests fetched by Angular's compiler
'/src/': './src/'
},
port: 9876,
// singleRun: true,
reporters: ['progress', 'dots', 'coverage'],
coverageReporter: {
reporters: [{
type: 'html'
}]
},
});
};
Karma test.shim
// Tun on full stack traces in errors to help debugging
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
// // Cancel Karma's synchronous start,
// // we will call `__karma__.start()` later, once all the specs are loaded.
__karma__.loaded = function() {};
System.config({
packages: {
'built': {
defaultExtension: false,
format: 'register',
map: Object.keys(window.__karma__.files).
filter(onlyAppFiles).
reduce(function createPathRecords(pathsMapping, appPath) {
// creates local module name mapping to global path with karma's fingerprint in path, e.g.:
// './hero.service': '/base/src/app/hero.service.js?f4523daf879cfb7310ef6242682ccf10b2041b3e'
var moduleName = appPath.replace(/^\/built\//, './').replace(/\.js$/, '');
pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]
return pathsMapping;
}, {})
}
}
});
System.import('angular2/testing').then(function(testing) {
return System.import('angular2/src/platform/browser/browser_adapter').then(function(providers) {
testing.setBaseTestProviders(providers.TEST_BROWSER_PLATFORM_PROVIDERS,
providers.TEST_BROWSER_APPLICATION_PROVIDERS);
});
}).then(function() {
return Promise.all(
Object.keys(window.__karma__.files) // All files served by Karma.
.filter(onlySpecFiles)
// .map(filePath2moduleName) // Normalize paths to module names.
.map(function(moduleName) {
// loads all spec files via their global module names (e.g. 'base/src/app/hero.service.spec')
return System.import(moduleName);
}));
})
.then(function() {
__karma__.start();
}, function(error) {
__karma__.error(error.stack || error);
});
function filePath2moduleName(filePath) {
return filePath.
replace(/^\//, ''). // remove / prefix
replace(/\.\w+$/, ''); // remove suffix
}
function onlyAppFiles(filePath) {
return /^\/built\/.*\.js$/.test(filePath)
}
function onlySpecFiles(path) {
return /.spec\.js$/.test(path);
}
Aucun commentaire:
Enregistrer un commentaire