I have a github seed here: https://github.com/Coly010/angular2-karma
What is the minimum setup required for testing to work with SystemJS and karma.
Karma.conf.js
// Karma configuration // Generated on Thu Jun 16 2016 11:08:35 GMT+0100 (GMT Summer Time) module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', // plugins needed for karma to work plugins: ['karma-systemjs', 'karma-jasmine', 'karma-chrome-launcher'], // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['systemjs', 'jasmine'], // need to set up SystemJS config for Karma systemjs : { configFile: 'systemjs.config.js', includeFiles: [ 'node_modules/reflect-metadata/Reflect.js', 'node_modules/zone.js/dist/zone.js' ], serveFiles: [ 'node_modules/@angular/**/*.js', 'lib/rxjs/**/*.js', 'bin/**/*.js' ], config: { paths: { 'systemjs': 'node_modules/systemjs/dist/system.src.js', 'system-polyfills': 'node_modules/systemjs/dist/system-polyfills.src.js', 'typescript': 'node_modules/typescript/lib/typescript.js', 'rxjs' : 'lib/rxjs/index.js', 'traceur': '/node_modules/traceur/dist/commonjs/traceur.js', 'reflect-metadata' : 'node_modules/reflect-metadata/Reflect.js', '@angular': '/node_modules/@angular/**/*.js', //'angular-mocks': '' } }, }, // list of files / patterns to load in the browser files: [ 'node_modules/reflect-metadata/Reflect.js', 'node_modules/zone.js/dist/zone.js', 'node_modules/@angular/**/*.js', 'lib/rxjs/**/*.js', 'bin/tests/*.spec.js' ], // list of files to exclude exclude: [ 'lib/rxjs/tools/*.js', ], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { }, // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress'], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['Chrome'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false, // Concurrency level // how many browser should be started simultaneous concurrency: Infinity }) }
systemjs.conf.js
/** * System configuration for Angular 2 samples * Adjust as necessary for your application needs. */ (function(global) { // map tells the System loader where to look for things var map = { 'src': 'src', // 'dist', 'bin': 'bin', '@angular': '/node_modules/@angular', 'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api', 'rxjs': '/lib/rxjs', 'crypto': '@empty', 'fs': '@empty', 'minimist': '@empty', 'path': '@empty', 'systemjs-builder': '@empty', 'browserify': '@empty', }; // packages tells the System loader how to load when no filename and/or no extension var packages = { 'src': { defaultExtension: 'js' }, 'bin': { 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', ]; // Individual files (~300 requests): function packIndex(pkgName) { packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' }; } // Bundled (~40 requests): function packUmd(pkgName) { packages['@angular/'+pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' }; }; // Most environments should use UMD; some (Karma) need the individual index files var setPackageConfig = System.packageWithIndex ? packIndex : packUmd; // Add package entries for angular packages ngPackageNames.forEach(setPackageConfig); var config = { "transpiler": "typescript", "typescriptOptions": { "module": "commonjs", "emitDecoratorMetadata": true }, meta: { '/node_modules/systemjs/dist/system.src.js': {format: 'global'} }, map: map, packages: packages } System.config(config); })(this);
hope this helps