Exclude files in Sonar Code Coverage Analysis Test - Angular 7

Viewed 8604

How do I exclude ts.files in SonarQube Analysis for better Code Coverage.

I tried with with below code

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "codeCoverageExclude": [
              "src/app/user/about-report/about-report.component.ts"
            ],
          }
       }

But no luck its is getting analized in sonar. Can you help me out. I am using Angular 7.

2 Answers

In sonar-project.properties , Try adding something like:

sonar.exclusions= **/*.spec.ts, **/*.ts, src/test/*

There is the following directive that can be used in the sonar-project.properties file:

sonar.coverage.exclusions=src/main/webapp

Or via website, go to Administration > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property

Related