angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Test Coverage Integration?

Open SethDavenport opened this issue 10 years ago • 27 comments

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Mac OS X (El Capitan)

  1. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version And paste the result here.

angular-cli: 1.0.0-beta.5 node: 6.0.0 os: darwin x64

(node 6.0.0)

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

None - feature request.

  1. The log given by the failure. Normally this include a stack trace and some more information.

None - feature request.

  1. Mention any other details that might be useful.

Angular-cli sets up Karma/Jasmine and basic unit tests which is really nice; thanks for that. However I'm wondering if there are plans to integrate code coverage reporting and threshold checking into the ng test flow (e.g. with Istanbul/Isparta, or similar).

In my company's starter kits we have a shortlist of things we consider mandatory for a production toolchain; the ability to fail CI when unit test coverage drops below a certain threshold is one of them.

Is code coverage on your radar?

SethDavenport avatar May 21 '16 21:05 SethDavenport

ng test --code-coverage created code coverage for me.

aniruddhadas9 avatar May 08 '17 16:05 aniruddhadas9

I agree with @yfain. It is not going to fail with Angular CLI 1.0.1. It keeps getting success even I have all threshold 100%.

SURENDARREDDY avatar May 09 '17 23:05 SURENDARREDDY

After upgrading the karma-coverage-istanbul-reporter to 1.2.1 it works as expected.

yfain avatar May 09 '17 23:05 yfain

Thank you @yfain, it is working now...

SURENDARREDDY avatar May 10 '17 15:05 SURENDARREDDY

I can confirm. I updated karma-coverage-istanbul-reporter to 1.2.1 and now I can use the threshold property in the coverageIstanbulReporter config like so:

        coverageIstanbulReporter: {
            reports: ['html', 'json'],
            fixWebpackSourcePaths: true,
            thresholds: config.angularCli.codeCoverage ? {
                each: { // thresholds per file
                    statements: 80,
                    lines: 80,
                    branches: 80,
                    functions: 80
                }
            } : {}
        },

This example I made only applies thresholds when code coverage is enabled in the build, else it will use out of date coverage reports.

ajdaniel avatar May 11 '17 09:05 ajdaniel

Am I the only one that finds these config files to be incredibly nuanced and poorly documented over time? What is the point of including this in angular-cli if it doesn't configure it correctly, automatically?

ghost avatar Jun 12 '17 17:06 ghost

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.