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

How to Exclude a folder with typeScript from karma & coverage. #221

Closed
FJLopezGarcia opened this issue Feb 3, 2017 · 8 comments
Closed

Comments

@FJLopezGarcia
Copy link

FJLopezGarcia commented Feb 3, 2017

Hi, do you know how to Exclude a folder that contains TypeScripts from karma coverage?

@lathonez
Copy link
Owner

lathonez commented Feb 3, 2017 via email

@emroussel
Copy link

I added this inside remapIstanbulReporter in karma.conf.js to exclude set up files from test coverage

remapIstanbulReporter: {
  remapOptions: {
    exclude: /src\/(mocks.ts|test.ts|polyfills.ts)/
  }
},

You can modify the regex to match the path of the folders you want to exclude.

@FJLopezGarcia
Copy link
Author

FJLopezGarcia commented Feb 5, 2017

thanks a lot @lathonez and @emmanuelroussel.

Do you know how to exclude two different paths with regex ?? I need to exclude /src/(mocks.ts|test.ts|polyfills.ts)/ and two new files (api.ts and CompanyApi.ts) from src/app/common/api/ path.

Thanks a lot for your help!!

@emroussel
Copy link

I think you can simply add the rest of the path of api.ts and CompanyApi.ts to the regex like this

/src/(mocks.ts|test.ts|polyfills.ts|app/common/api/api.ts|app/common/api/CompanyApi.ts)/

It gets a bit ugly, but it should work.

@emroussel
Copy link

@lathonez would like me to make a PR to exclude test config files from test coverage by default?

@lathonez
Copy link
Owner

lathonez commented Feb 5, 2017

@emmanuelroussel - I would, but it should be a PR to ng-cli not to us:

angular/angular-cli#3356

@jquagliatini
Copy link

@filipesilva provided a new syntax for the .angular-cli.json file

angular/angular-cli#4966

  "test": {
    "codeCoverage": {
      "exclude": [
        "src/polyfills.ts",
        "**/test.ts"
      ]
    },
    "karma": {
      "config": "./karma.conf.js"
    }
  },

@lathonez
Copy link
Owner

lathonez commented Mar 1, 2017

@1M0reBug awesome, thanks for the reference.

Reopening to track merging the upstream change.

@lathonez lathonez reopened this Mar 1, 2017
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

4 participants