karma-coverage icon indicating copy to clipboard operation
karma-coverage copied to clipboard

Coverage with Webpack not work

Open Merynek opened this issue 3 years ago • 1 comments

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?

Merynek avatar Apr 27 '22 16:04 Merynek

Anyone figured this out?

dsilhavy avatar Mar 04 '24 09:03 dsilhavy