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

Coverage being generated for sources that are not being tested #236

Closed
parky128 opened this issue Jan 9, 2018 · 3 comments
Closed

Coverage being generated for sources that are not being tested #236

parky128 opened this issue Jan 9, 2018 · 3 comments
Labels

Comments

@parky128
Copy link

parky128 commented Jan 9, 2018

I have just started using this plugin for an angularJS application and have so far setup a very simple test for a service I have:

import { GpsService } from "./gps.service";

describe("Service", () => {
  let gpsService: GpsService;

  beforeEach(() =>{
    angular.mock.module("app.services");
    angular.mock.module(function($provide) {
      $provide.factory('endpointsurls', function() {
        return {};
      });
    });
  });

  beforeEach(inject((_gpsService_) => {
    gpsService = _gpsService_;
  }));

  it('should do something', () => {
    gpsService.getGPSFix();
    expect(1).toEqual(1);
  })
});

This is just a dummy test as you can probably tell, but I wanted to prove I could call a method on my service and see it picked up in my coverage report.

I do indeed see the file covered by the output html report, but I also see my other TS sources showing with coverage even though I havent written any specs for these. Is this normal behaviour? I was hoping I would see zero coverage for anything that doesnt have a spec file associated, is this a config option?

image

Thanks

@erikbarke
Copy link
Collaborator

This is expected behavior, but you can exclude files from the coverage report by using the setting karmaTypescriptConfig.coverageOptions.exclude, as suggested in #116!

@parky128
Copy link
Author

parky128 commented Jan 9, 2018

Thanks @erikbarke

I will take a look at this further 👍

@erikbarke
Copy link
Collaborator

Closing this, feel free to reopen if you need!

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

No branches or pull requests

2 participants