I am trying to get the Code Coverage for my typescript Code in karma framework using Istanbul in karma.conf typescript files are included and by karma typescript-preprocessor we able to do unit testing and code coverage of the typescript code but Code coverage report come for trans piled JavaScript code
How can I get the coverage report for typescript code?
Here is my karma.conf
file.
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
preprocessors: {
'src/**/*.ts': ['typescript', 'coverage'],
'test/**/*.ts': ['typescript']
},
typescriptPreprocessor: {
options: {
sourceMap: false, // (optional) Generates corresponding .map file.
target: 'ES5', // (optional) Specify ECMAScript target version: 'ES3' (default), or 'ES5'
module: 'amd', // (optional) Specify module code generation: 'commonjs' or 'amd'
noImplicitAny: true, // (optional) Warn on expressions and declarations with an implied 'any' type.
noResolve: false, // (optional) Skip resolution and preprocessing.
removeComments: true, // (optional) Do not emit comments to output.
concatenateOutput: false // (optional) Concatenate and emit output to single file. By default true if module option is omited, otherwise false.
},
// extra typing definitions to pass to the compiler (globs allowed)
// transforming the filenames
transformPath: function (path) {
return path.replace(/\.ts$/, '.js');
}
//options: {
// sourceMap: true,
//}
},
// list of files / patterns to load in the browser
files: [
'src/**/*.ts',
'test/**/*.ts'
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress','coverage'],
// 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, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
plugins: [
'karma-jasmine',
'karma-chrome-launcher',
'karma-phantomjs-launcher',
'karma-typescript-preprocessor',
'karma-coverage'
//require('../../../node_modules/karma-typescript-preprocessor/index.js')
]
});
};