jeudi 7 novembre 2019

How to get test coverage with test written in js and testing files in typescript on Karma

I wonder is possible to have test coverage of .ts files on Karma. I have all test written in javascript and I started migrating to typescript my source files After that migrate all test are OK, I mean .ts files being tested. But unfortunately test coverage of typescript files disappear.

As I said test are written in javascript. Some of ./src files are in .ts some in .js

There is my Karma config

 config.set({
    frameworks: ['jasmine-ajax', 'jasmine'],
    reporters:['mocha','coverage'],
    files: [
      { pattern: 'test/**/*_test.js', watched: false }
    ],
    colors: true,
    autoWatch: true,
    singleRun: false,
    coverageReporter: {
      dir: '.',
      reporters: [
        { type: 'text', subdir: 'coverage' },
        { type: 'html', subdir: 'coverage' },
        { type: 'lcovonly', subdir: '.', file: 'lcov.info' }
      ]
    },
    preprocessors: {
      'test/**/*_test.js': ['webpack', 'sourcemap']
    },
    webpack: build.config('test'),
    webpackMiddleware: {
      stats: 'errors-only'
    },
    browsers: BROWSERS,
    client: {
      captureConsole: false,
      mocha: {
        bail: true
      }
    }
  })

My webpack contain babel-loader for .js files and ts-loader for .ts files

Aucun commentaire:

Enregistrer un commentaire