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 report not showing files with zero coverage #556

Open
masterqwerty opened this issue Apr 13, 2022 · 0 comments
Open

Coverage report not showing files with zero coverage #556

masterqwerty opened this issue Apr 13, 2022 · 0 comments

Comments

@masterqwerty
Copy link

I don't know if this is a bug in this library or my configuration, but when I run a coverage report using the karma-typescript reporter, it only reports on files that have unit tests for them. In other words, I'm seeing something like this:

-------------------------------------------|---------|----------|---------|---------|-------------------
File                                       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------------------------|---------|----------|---------|---------|-------------------
All files                                  |     100 |      100 |     100 |     100 |
 src                                       |     100 |      100 |     100 |     100 |
  test.ts                                  |     100 |      100 |     100 |     100 |

Instead of something like this:

-------------------------------------------|---------|----------|---------|---------|-------------------
File                                       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------------------------------|---------|----------|---------|---------|-------------------
All files                                  |      50 |       50 |      50 |      50 |
 src                                       |     100 |      100 |     100 |     100 |
  test.ts                                  |     100 |      100 |     100 |     100 |
  uncovered.ts                             |       0 |        0 |       0 |       0 | 1-25

The test command is ng test my-application --watch=false --browsers=ChromeHeadlessNoSandbox --code-coverage.

This is my karma.conf.js:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular', 'karma-typescript'],
    plugins: [
      'karma-jasmine',
      'karma-chrome-launcher',
      'karma-jasmine-html-reporter',
      'karma-coverage',
      'karma-typescript',
      '@angular-devkit/build-angular/plugins/karma'
    ],
    client: {
      clearContext: false
    },
    preprocessors: {
      '**/*.ts': ['karma-typescript']
    },
    karmaTypescriptConfig: {
      reports: {
        'text': null,
        'text-summary': {
          'directory': 'coverage',
          'subdirectory': '.',
          'filename': 'summary.txt'
        },
        'json-summary': {
          'directory': 'coverage',
          'subdirectory': '.',
          'filename': 'summary.json'
        }
      },
      tsconfig: 'tsconfig.lib.json'
    },
    reporters: ['progress', 'kjhtml', 'karma-typescript'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome', 'ChromeHeadless'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: ['--no-sandbox']
      }
    },

    singleRun: false
  });
};

And this is my tsconfig.lib.json:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "declarationMap": true,
    "target": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "declaration": true,
    "sourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "types": ["webgl2"],
    "lib": [
      "dom",
      "es2015"
    ]
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

Any help would be appreciated. Thanks!

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

1 participant