Angular-cli: Tests no longer failing on code coverage lower than threshold

Created on 5 Sep 2018  路  6Comments  路  Source: angular/angular-cli

_From @pkspks on May 18, 2018 4:16_

Bug Report or Feature Request (mark with an x)

- [x] bug report 
- [ ] feature request

Area

- [x] devkit
- [ ] schematics

Versions

$ npm --version
6.0.1
$ node --version
v10.1.0



md5-d08130cdaca3774009cf393eba1826be



$ npm list @angular-devkit/build-angular
.....
`-- @angular-devkit/[email protected]



md5-8ed019dc1bbbafdb275cd43f36471983



    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, 'coverage'),
      reports: ['html', 'lcovonly', 'cobertura'],
      fixWebpackSourcePaths: true,
      thresholds: {
        statements: 98,
        branches: 80,
        functions: 97,
        lines: 98
      }
    },



md5-b77a24966a3c93eef50fae9f5069e0eb



$ ng test --code-coverage                                                                                                                                                                              
 10% building modules 1/1 modules 0 active(node:11812) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead                                                               
18 05 2018 14:12:50.973:INFO [karma]: Karma v2.0.2 server started at http://0.0.0.0:9876/                                                                                                              
18 05 2018 14:12:50.979:INFO [launcher]: Launching browser Chrome with unlimited concurrency                                                                                                           
18 05 2018 14:12:50.988:INFO [launcher]: Starting browser Chrome                                                                                               18 05 2018 14:13:02.930:INFO [Chrome 66.
3359 (Windows 10 0.0.0)]: Connected on socket xnq32DY33fYmjFJGAAAA with id 69646099                                                                                                                    
.........................................                                                                                                                                                              
Chrome 66.0.3359 (Windows 10 0.0.0): Executed 41 of 41 SUCCESS (0.52 secs / 0.446 secs)                                                                                                                
18 05 2018 14:13:06.579:ERROR [reporter.coverage-istanbul]: Coverage for statements (97.99%) does not meet global threshold (98%)                                                                      
18 05 2018 14:13:06.580:ERROR [reporter.coverage-istanbul]: Coverage for functions (96%) does not meet global threshold (97%)                                                                          

---------                                                                                                                                          
$ echo $?                                                                                                                                                                                              
0                                                                                                                                                                                                      

Desired functionality

Mention any other details that might be useful


Exit code should be 1 like it was with Angular 4.

_Copied from original issue: angular/devkit#935_

devkibuild-angular medium regression bufix

All 6 comments

This is due that ng test runs in watch mode by default. For it to exit with a non zero error code you need to turn this off. You can do it by using the --no-watch or --watch=false

Example;

ng test --code-coverage --no-watch

@alan-agius4 , not really. This was reported in a particular version and is still reproducible on that version. It's no longer reproducible on ~0.8.1 which I have now upgraded to.
Karma was set to singleRun to be true which should cause watch be false.

Can I use ~0.8.1 with Angular 6.0.6 or I need to upgrade Angular? It would be nice to know what was the fix because I'm running into the same issue and upgrade Angular is not an option for the moment.

I am having the same issue with what i believe is all the latest bits:
I am using the --no-watch argument, and I can confirm the karma-coverage-istanbul-reporter is returning exitCode=1 to the karmalibserver into the disconnectBrowsers() function, but it doesn't look like the obs.complete() observable is consuming this exitCode.

can you please provide some guidance?
i have created new (basically empty) angular library project with:
node = v10.15.2; npm = 6.4.1;
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.5",

PS C:_projectsWebkinetic-erp> ng test kinetic-erp --no-watch --code-coverage
14 03 2019 16:17:41.619:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
14 03 2019 16:17:41.632:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
14 03 2019 16:17:41.642:INFO [launcher]: Starting browser Chrome
14 03 2019 16:17:50.625:INFO [Chrome 72.0.3626 (Windows 10.0.0)]: Connected on socket QAQfsPPIi19zhkgAAAAA with id 62310915
Chrome 72.0.3626 (Windows 10.0.0): Executed 3 of 3 SUCCESS (0.063 secs / 0.123 secs)
TOTAL: 3 SUCCESS
TOTAL: 3 SUCCESS
14 03 2019 16:17:54.537:ERROR [reporter.coverage-istanbul]: Coverage for branches (50%) does not meet global threshold (80%)
14 03 2019 16:17:54.539:ERROR [reporter.coverage-istanbul]: Coverage for functions (66.67%) does not meet global threshold (80%)
PS C:_projectsWebkinetic-erp> echo $?
True <--- it appears on windows, the value here is truthy to indicate success instead of the exitCode

I am having the same issue with what i believe is all the latest bits:
I am using the --no-watch argument, and I can confirm the karma-coverage-istanbul-reporter is returning exitCode=1 to the karmalibserver into the disconnectBrowsers() function, but it doesn't look like the obs.complete() observable is consuming this exitCode.

can you please provide some guidance?
i have created new (basically empty) angular library project with:
node = v10.15.2; npm = 6.4.1;
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.5",

PS C:_projectsWebkinetic-erp> ng test kinetic-erp --no-watch --code-coverage
14 03 2019 16:17:41.619:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
14 03 2019 16:17:41.632:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
14 03 2019 16:17:41.642:INFO [launcher]: Starting browser Chrome
14 03 2019 16:17:50.625:INFO [Chrome 72.0.3626 (Windows 10.0.0)]: Connected on socket QAQfsPPIi19zhkgAAAAA with id 62310915
Chrome 72.0.3626 (Windows 10.0.0): Executed 3 of 3 SUCCESS (0.063 secs / 0.123 secs)
TOTAL: 3 SUCCESS
TOTAL: 3 SUCCESS
14 03 2019 16:17:54.537:ERROR [reporter.coverage-istanbul]: Coverage for branches (50%) does not meet global threshold (80%)
14 03 2019 16:17:54.539:ERROR [reporter.coverage-istanbul]: Coverage for functions (66.67%) does not meet global threshold (80%)
PS C:_projectsWebkinetic-erp> echo $?
True <--- it appears on windows, the value here is truthy to indicate success instead of the exitCode

Facing Same issue. Any leads?

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MateenKadwaikar picture MateenKadwaikar  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

brtnshrdr picture brtnshrdr  路  3Comments

donaldallen picture donaldallen  路  3Comments

hareeshav picture hareeshav  路  3Comments