I am trying to check my directive with karma and webpack. This is a karma configuration file
module.exports = function (config) { config.set({ basePath: './', frameworks: ["jasmine"], files: [ { pattern: 'directive.spec.ts', watched: false }], exclude: [], preprocessors: { 'directive.spec.ts': ['webpack', 'sourcemap'] }, webpackServer: { noInfo: true }, port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: false, browsers: [ "PhantomJS" ], singleRun: true, reporters: ['mocha'], webpack: { resolve: { extensions: ['', '.ts', '.js'], modulesDirectories: ['node_modules', '.'], }, module: { loaders: [{ test: /\.ts$/, loader: 'awesome-typescript-loader' }] }, stats: { colors: true, reasons: true }, debug: true, devtool: 'inline-source-map' } }); };
And the .spec.ts directive:
import { MyDirective } from './directive'; import {TestComponent} from './test'; import { async, inject, TestBed, } from '@angular/core/testing'; describe('TestComponent', () => { let fixture: any; beforeEach(() => { fixture = TestBed.configureTestingModule({ declarations: [ TestComponent, MyDirective] }) .createComponent(TestComponent); fixture.detectChanges(); }); it('should work', () => { expect(true).toBe(true); });
But when I try to run my test, I get this error:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR ReferenceError: cannot find variable: Map at directive.spec.ts: 1380
What am I missing here?