karma-runner / karma-runner/karma-coverage

Coverage with Webpack not work

Open
#474 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

I have this config:
It works but coverage is on test files only. So 100% :-)).
I need coverage only on .ts files, but I dont know how set preprocessor only to .ts files.
```
module.exports = function (config) {
config.set({
frameworks: ["jasmine", "webpack"],
reporters: ['progress', 'coverage'],
files: [
{
pattern: `${outputPath}/**/*`, // <-- here
watched: false,
included: false
},
"./test/boot.spec.ts",
"./src/app/**/*.ts", // *.tsx for React Jsx
"./test/**/*.ts" // *.tsx for React Jsx
],
preprocessors: {
// add webpack as preprocessor
'test/**/*.ts': ['webpack', 'coverage']
},
coverageReporter: {
type : 'html',
dir : '../coverage/Pico'
},
webpack: webpackConfig,
browsers: ["Chrome"],
logLevel: config.LOG_ERROR
});
};
```

I try this:
```
module.exports = function (config) {
config.set({
frameworks: ["jasmine", "webpack"],
reporters: ['progress', 'coverage'],
files: [
{
pattern: `${outputPath}/**/*`, // <-- here
watched: false,
included: false
},
"./test/boot.spec.ts",
"./src/app/**/*.ts", // *.tsx for React Jsx
"./test/**/*.ts" // *.tsx for React Jsx
],
preprocessors: {
// add webpack as preprocessor
'test/**/*.ts': ['webpack'],
"./src/app/**/*.ts": ['webpack', 'coverage']
},
coverageReporter: {
type : 'html',
dir : '../coverage/Pico'
},
webpack: webpackConfig,
browsers: ["Chrome"],
logLevel: config.LOG_ERROR
});
};
```
But I got error: ultiple assets emit different content to the same filename on assets, bcs Loaded more than once.

Any Idea?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.