I have seen problems like this in the past. In 99% of cases, this is due to the fact that the file in the karma.conf.js array karma.conf.js not a file that refers to the application.
Another probable problem is that the module names are incorrectly translated from their respective file names.
Here is a snippet of my karma-test-shim.js where I rewrite the file names into module names:
System.config({ packages: { 'base/wwwroot/app': { defaultExtension: false, format: 'register', map: Object.keys(window.__karma__.files). filter(function onlyAppFiles(filePath) { return /^\/base\/wwwroot\/app\/.*\.js$/.test(filePath) }). reduce(function createPathRecords(pathsMapping, appPath) { // creates local module name mapping to global path with karma fingerprint in path, eg: var moduleName = appPath.replace(/^\/base\/wwwroot\/app\//, './').replace(/\.js$/, ''); pathsMapping[moduleName] = appPath + '?' + window.__karma__.files[appPath]; return pathsMapping; }, {}) } } });
The structure of my project:
/ karma.conf.js karma-test-shim.js wwwroot/ app/ //Angular 2 project and spec files
Julia Ralph, the developer of the Angular 2 team, has an initial project for setting up karma tests for the Angular 2 project, which I thought was very useful in creating a karma pad.
source share