So, I have an angular 1.5 application that I compile with Typescript and then link it through Browserify.
Now, when I want to test it with Karma and Jasmine, I get an error message as soon as I want to enter the service (it works fine in a browser with strict-di enabled).
Does anyone see where the error is?
CacheServiceTest.ts
import {CacheService} from "../../../app/services/CacheService";
import {Application} from "../../../app/Application";
describe("AppComponent", () => {
beforeEach(() => {
angular.mock.module(Application.name);
});
it("should contain CacheService", () => {
inject((CacheService:CacheService) => {
console.log(CacheService);
});
});
});
Karma configuration
module.exports = function (config) {
config.set({
basePath: "..",
frameworks: ["jasmine", "browserify"],
files: [
"node_modules/angular/angular.js",
"node_modules/angular-mocks/angular-mocks.js",
"node_modules/ngLeague/dist/ngLeague.js",
"node_modules/angular-localforage/dist/angular-localForage.js",
"app/**/*.ts",
"tests/unit/**/*.ts",
{
pattern: "tests/fixtures/**/*.json",
watched: true,
served: true,
included: false
}
],
exclude: [],
preprocessors: {
"app/**/*.ts": ["browserify", "ng-annotate"],
"tests/unit/**/*.ts": ["browserify", "ng-annotate"],
"dist/ngCache.js": "coverage"
},
browserify: {
debug: true,
plugin: [
["tsify", {target: "ES5"}]
]
},
reporters: ["progress", "coverage"],
coverageReporter: {
type : "html",
dir : "tests/coverage/"
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ["PhantomJS"],
singleRun: false
});
};
Error
forEach@/home/kme/Documents/ngCache/node_modules/angular/angular.js:322:24
loadModules@/home/kme/Documents/ngCache/node_modules/angular/angular.js:4548:12
createInjector@/home/kme/Documents/ngCache/node_modules/angular/angular.js:4470:30
workFn@/home/kme/Documents/ngCache/node_modules/angular-mocks/angular-mocks.js:2954:60
inject@/home/kme/Documents/ngCache/node_modules/angular-mocks/angular-mocks.js:2934:46
/tmp/fe42636aeb0f927c8dcd9afa7c80f051.browserify:16447:15 <- tests/unit/services/CacheServiceTest.ts:14:15
/home/kme/Documents/ngCache/node_modules/angular/angular.js:4588:53