Code coverage getting dropped when we combine code coverage from karma unit test case and from cypress integration test case

Aperta
#591 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
angular, cypress, node.js, typescript
Ambito
testing

Direzione di ricerca

Inizia con gli esempi .nycrc.json e Karma.config.js, quindi esamina .nyc_output/out.json e i file JSON di coverage separati di Karma e Cypress per riprodurre il merge. Confronta i relativi percorsi dei file e gli identificatori di coverage; il lavoro è completato quando la riduzione segnalata viene riprodotta e ne vengono stabiliti la causa o il comportamento previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Logs and screenshots
I have angular 14 project where I am using karma framework for unit testing and cypress for integration test. I have separate code coverage for karma unit test and cypress integration test and I have combined both code coverage json files but code coverage got dropped after merging. I think code coverage is taking delta of them.

Karma Unit test case coverage:-

karma

Cypress Integration code coverage:-

cypress

Combined Code coverage:-

combine

If you see above reports, I am expecting combine report should show 100 % code coverage for components/sym-ui-sedr-actions because I have covered the component in integration test but it was showing delta. Is there any solution?

Versions

Cypress 10.8.0
"cypress-parallel": "0.9.1",
"@cypress/code-coverage": "3.10.0",
Angular 12.1.3
os : windows 10, linux
Node v12.22.3
npm v6.14.13
application instrumented using istambul and followed below lnk
https://lukas-klement.medium.com/implementing-code-coverage-with-angular-and-cypress-6ed08ed7e617

window.coverage : yes

Is there .nyc_output folder? Is there .nyc_output/out.json file.
-yes
Do you have any custom NYC settings in package.json (nyc object) or in other [NYC config files]
yes

{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"excludeAfterRemap": true,
"reporter": ["html"],
"exclude": [
"./coverage/",
"cypress/",
"./dist/",
"/.spec.ts",
"/projects//test.ts",
"/projects//.js",
"./.js",
"./.config.ts",
"/projects//*.html",
"./src/**"
]
}

Do you run Cypress tests in a Docker container?
NO

Describe the bug
If you see above reports, I am expecting combine report should show 100 % code coverage for components/sym-ui-sedr-actions because I have covered the component in integration test but it was showing delta. Is there any solution?

FYI I am using Istanbul for instrumenting code for karma as well as for cypress

Example
.nycrc.json

{
  "extends": "@istanbuljs/nyc-config-typescript",
  "all": true,
  "excludeAfterRemap": true,
  "exclude": [
    "./coverage/**",
    "cypress/**",
    "./dist/**",
    "**/*.spec.ts",
    "**/projects/**/test.ts",
    "**/projects/**/*.js",
    "./*.js",
    "./*.config.ts",
    "**/projects/**/*.html",
    "./src/**"
  ]
}

Krama.config.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-firefox-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-json-reporter'),
      require('karma-coverage'),
      require('karma-spec-reporter'),
      require('@angular-devkit/build-angular/plugins/karma'),
    ],
    client: {
      jasmine: {
        random: false,
        seed: '4321',
        oneFailurePerSpec: true,
        failFast: true,
        timeoutInterval: 30 * 1000,
      },
      clearContext: false, // leave Jasmine Spec Runner output visible in browser
    },
    jasmineHtmlReporter: {
      suppressAll: true, // removes the duplicated traces
    },
    coverageReporter: {
      check: {
        emitWarning: false,
        global: {
          statements: 85.42,
          branches: 70,
          functions: 84.37,
          lines: 81.76,
          excludes: ['src/**/*.js'],
        },
      },
      dir: require('path').join(__dirname, '../../../coverage/sym-ui/sedr'),
      instrumenterOptions: {
        istanbul: { noCompact: true },
      },
      reporters: [{ type: 'html' },{ type: 'json' }, { type: 'text-summary' }],
      subdir: '.',
      watermarks: {
        statements: [60, 85],
        functions: [60, 85],
        branches: [60, 85],
        lines: [60, 85],
      },
    },
    reporters: ['spec', 'progress', 'kjhtml', 'json'],
    port: 0,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    // Start these browsers, currently available:
    // - ChromeHeadlessNoSandbox
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - IE (only Windows)
    browsers: ['ChromeHeadlessNoSandbox'],
    customLaunchers: {
      ChromeHeadlessNoSandbox: {
        base: 'ChromeHeadless',
        flags: [
            '--disable-web-security',
            '--disable-gpu',
            '--no-sandbox'
        ]
      },
    },
    captureTimeout: 100 * 1000,
    reportSlowerThan: 5000,
    singleRun: false,
    restartOnFileChange: true,
    browserDisconnectTimeout: 100 * 1000,
    browserDisconnectTolerance: 8,
    browserNoActivityTimeout: 100 * 1000,
  });
};
Lingua principale
TypeScript
Stelle
440
Fork
114
Merge medio
42m
PR unite (30g)
19

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cypress-io/code-coverage

Tutte le issue di cypress-io/code-coverage

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.