As I try to run Karma Tests in Angular2, I encounter the following error message.
An Unexpected anonymous System.register call is causing an Uncaught TypeError at http://localhost:9876/base/node_modules/systemjs/dist/system.src.js?38538ebca96bc7b222f7e7ba15943f173a485f6e:2885
This seems to be happening because the var System is not available, even though it has been loaded. Can anyone suggest why this issue is occurring?
Below is a simplified version of my configuration:
C:\project\karma.conf.js
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'node_modules/systemjs/dist/system.src.js',
'node_modules/angular2/bundles/angular2.dev.js',
'tests/**/*Spec.js'
],
exclude: [
],
preprocessors: {
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Chrome', 'Firefox'],
singleRun: false,
concurrency: Infinity
})
}
C:\project\tests\MyTestSpec.ts The error is triggered by just this line.
import {describe, expect, it, xit, inject, beforeEachProviders} from 'angular2/testing';
This code translates to C:\project\tests\MyTestSpec.js and the error occurs when encountering the first instance of System
System.register([], function(exports_1) {
return {
setters:[],
execute: function() {
}
}
});
//# sourceMappingURL=CmiCloudSpec.js.map
C:\project\tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"watch": true,
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
C:\project\src\node_modules
contains the folders angular2 and systemjs as well as karma, karma-jasmine, jasmine-core and typescript