Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to Generate istanbul coverage in json format #397

Closed
bharathmuppa opened this issue Aug 19, 2020 · 1 comment
Closed

Not able to Generate istanbul coverage in json format #397

bharathmuppa opened this issue Aug 19, 2020 · 1 comment

Comments

@bharathmuppa
Copy link

I have the following karma configuration and I expect coverage folder to be created with JSON format. But the default HTML report is being generated instead of JSON.

Versions of packages

"karma-typescript": "5.1.0",
"karma": "5.1.1",
"karma-browserstack-launcher": "1.3.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.1",
"karma-jasmine-html-reporter": "1.5.4"

karma.conf.js


module.exports = function(config) {
    config.set({
        frameworks: ['polyfill', 'jasmine', 'karma-typescript'],

        files: [
            { pattern: '../**/*.ts' }
        ],

        exclude: ['../core/**/*.spec.ts', '../ng-core-containers/**/*', '../ng-core-services/**/*'],

        logLevel: config.LOG_INFO,

        preprocessors: {
            '../**/*.ts': ['karma-typescript']
        },

        reporters: ['progress', 'ipf', 'karma-typescript'],

        ipfReporter: {
            outputFile: '../../Output/tests/integration/core-integration.Results.xml',
            suite: 'core-integration',
            component: 'WebAde',
            isJasmine: true
        },
        polyfill: [
            'Promise',
            'Array.prototype.find',
            'Array.prototype.findIndex',
            'Array.from',
            'Math.sign',
            'Function.name'
        ],
        browsers: ['Chrome'],
        karmaTypescriptConfig: {
            // coverageReporter: {
            //     instrumenterOptions: {
            //         istanbul: { noCompact: false }
            //     }
            // },
            reporters: {
                json: {
                    directory: 'coverage-json', // optional, defaults to 'coverage'
                    subdirectory: 'json', // optional, defaults to the name of the browser running the tests
                    filename: 'coverage.json' // optional, defaults to the report name
                }
            },
            include: ['../**/*.ts'],
            exclude: ['../core/**/*.spec.ts'],
            tsconfig: './tsconfig.spec.json',
            compilerOptions: {
                module: 'commonjs'
            }
        },
        singleRun: true,
        client: {
            captureConsole: false
        }
    });
};

@erikbarke
Copy link
Collaborator

There's a typo in your config, reporters: {... should be reports: {... 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants