Install karma-typescript :
npm install karma-typescript
Put this in your karma.conf.js:
frameworks: ["jasmine", "karma-typescript"], files: [ { pattern: "src/**/*.ts" } ], preprocessors: { "**/*.ts": ["karma-typescript"] }, reporters: ["progress", "karma-typescript"], browsers: ["Chrome"]
This will run your Typescript test tests on the fly and generate Istanbul html coverage that looks like this:

To run the above example, you need to install several packages:
npm install @types/jasmine jasmine-core karma karma-chrome-launcher karma-cli karma-jasmine karma-typescript typescript
This is the complete configuration for unit testing Typescript vanilla code, not the tsconfig.json required in this case. For more complex settings with Angular, React, etc. You can find examples in the examples folder and in integration tests .
Erik barke
source share