Questions tagged [karma-coverage]

A plugin for Karma (code test runner) that generate code coverage.

A plugin. Generate code coverage.

295 questions
67
votes
4 answers

Testing error case with observables in services

Let's say I have a component that subscribes to a service function: export class Component { ... ngOnInit() { this.service.doStuff().subscribe( (data: IData) => { doThings(data); }, …
57
votes
1 answer

What are the differences between karma reporters?

I am looking at karma's reporter configuration. There are some possible reporters: progress, dots, growl, coverage. I don't find any detailed information explaining each of the options. I tried progress and dots, they all print log to console, the…
Aaron Shen
  • 8,124
  • 10
  • 44
  • 86
42
votes
2 answers

How do I exclude files from karma code coverage report?

Is there a way to exclude files from code coverage report for the karma coverage runner https://github.com/karma-runner/karma-coverage ?
Subtubes
  • 15,851
  • 22
  • 70
  • 105
41
votes
1 answer

How to change the format of the LCOV report executed by Karma?

I've configured Karma to report the coverage of my JavaScript code. Here is the part of the configuration in the karma.conf.js file: coverageReporter: { reporters: [ { type: 'html', dir: 'build/karma/coverage' }, { …
Romain Linsolas
  • 79,475
  • 49
  • 202
  • 273
26
votes
11 answers

No binary for PhantomJS browser on your platform. Please, set "PHANTOMJS_BIN" env variable

My package.json looks like this.. "karma-phantomjs-launcher": "^0.1.4", "karma-safari-launcher": "^0.1.1", "karma-sinon-chai": "~0.2.0", "karma-spec-reporter": "~0.0.16", "mocha": "~1.20.1" my npm version is 2.2.0 whay am I getting this when I run…
Sanath
  • 4,774
  • 10
  • 51
  • 81
25
votes
2 answers

Angular 11 Unit Test Code Coverage is Now Breaking

Prior to upgrading to Angular 11, I ran my unit tests with code coverage via the following command: ng test --project my-app --code-coverage true When I upgraded my project to Angular 11, I was still able to do my code coverage tests, but I started…
20
votes
2 answers

After Upgrading to Angular 13 the tests with --code-coverage is failing

After Upgrading to Angular 13 the tests which are run with --code-coverage are failing with error that some plugin is missing I am using karma-coverage-istanbul-reporter on the karma.conf.js and this is causing some issue. I even replaced this with…
Sudharshan
  • 3,634
  • 2
  • 27
  • 27
20
votes
3 answers

Karma , Istanbul - code coverage report Unknown% ( 0/0 )

I'm getting this Coverage Summary =============================== Coverage summary =============================== Statements : Unknown% ( 0/0 ) Branches : Unknown% ( 0/0 ) Functions : Unknown% ( 0/0 ) Lines : Unknown% ( 0/0…
18
votes
0 answers

How to do code coverage with karma, typescript, and browserify

How do you setup karma test runner to generate code coverage reports of a typescript project? Given the following folder structure and karma.conf.js file I'm already using karma to run my tests written in TypeScript. I already fiddled around with…
Oliver
  • 978
  • 6
  • 17
15
votes
2 answers

else path not taken in unit testing

I am working on angular 6 I don't have any else statement in my below code.But I am unable to cover branches due to else path not taken .What I need to do to get 100% branch coverage in this case? getHeaderDocumentList(documents: any) { …
Ramesh Rajendran
  • 37,412
  • 45
  • 153
  • 234
15
votes
1 answer

what does 1x 3x etc mean in karma code coverage report in Angular Unit testing?

I am new to Unit Testing in Angular. I got the karma setup with code coverage along with angular-cli . I have run the command ng-test and opened code coverage report. I saw 1x ,3x etc along with my code line numbers in that coverage report. Please…
14
votes
3 answers

How to unit test model interfaces in typescript?

export interface User { name: string; } How can I unit test the above interface, so Karma could show it in the code coverage report? I already tried creating the object and assert some properties, but didn't work. The test passes but karma…
brazuka
  • 1,011
  • 4
  • 13
  • 22
14
votes
4 answers

Branches on constructor not covered

I am creating my unit tests with Jasmine and I have a question about the branch covered. Does anyone know why the code part shows that the branches are not covered as we can see below? This is the unit test: describe('MyComponent', () => { let…
Marcio M.
  • 371
  • 1
  • 6
  • 15
14
votes
1 answer

Karma Code Coverage - Always 100%?

Good Morning, I am having a weird issue that I cannot seem to solve. I have my Karma tests written out and the execute correctly, but when I try to wire up the code coverage for Karma it just spits out 100% no matter what. I looked at the other…
Primm
  • 1,438
  • 3
  • 12
  • 16
13
votes
1 answer

Unexpected token while running karma-coverage on Typescript project

I have a basic Angular/Typescript project with 12 rudimentary unit tests that run perfectly fine. Now I would like to get the coverage for these tests. I tried various approaches, and none of them worked, so I decided to start over with…
1
2 3
19 20