karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

Karma fails with coverage reports #2661

Open AhmedHadjTaieb opened 7 years ago

AhmedHadjTaieb commented 7 years ago

Expected behaviour

I use jasmine with karma to my unit tests for project angular cli and I need the report of coverage. But when I use coverage and coverage-istanbul I found error.

Actual behaviour

karma start ./karma.conf.js

<--- Last few GCs --->

[5894:0x102801600] 169936 ms: Mark-sweep 1471.6 (1620.9) -> 1471.6 (1622.9) MB, 1062.8 / 0.0 ms allocation failure GC in old space requested [5894:0x102801600] 172240 ms: Mark-sweep 1471.6 (1622.9) -> 1471.5 (1591.9) MB, 2301.6 / 0.0 ms last resort [5894:0x102801600] 173719 ms: Mark-sweep 1471.5 (1591.9) -> 1471.5 (1591.9) MB, 1476.9 / 0.0 ms last resort

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3c0f442a6729 1: ExpressionStatement [/Users/AhmedHt/SiFAST PFE/socle-angular2/node_modules/escodegen/escodegen.js:~1291] [pc=0x307b6b430de](this=0x336274dd53c9 <a CodeGenerator with map 0xf8d8725b071>,stmt=0x27c65f5ac169 <a Node with map 0x24342b5ffea9>,flags=49) 2: generateStatement [/Users/AhmedHt/SiFAST PFE/socle-angular2/node_modules/escodegen/escodegen.js:~2465] [pc=0x307b6a50a83](this=0x336274...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node::Abort() [/usr/local/bin/node] 2: node::FatalException(v8::Isolate, v8::Local, v8::Local) [/usr/local/bin/node] 3: v8::internal::V8::FatalProcessOutOfMemory(char const, bool) [/usr/local/bin/node] 4: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node] 5: v8::internal::String::SlowFlatten(v8::internal::Handle, v8::internal::PretenureFlag) [/usr/local/bin/node] 6: v8::internal::Runtime_StringCharCodeAtRT(int, v8::internal::Object*, v8::internal::Isolate) [/usr/local/bin/node] 7: 0x307b580ed46 8: 0x307b6b430de 9: 0x307b6a50a83 10: 0x307b6a68a69 11: 0x307b5805cd5 12: 0x307b6b44983 13: 0x307b6a50a83 14: 0x307b881d398 Abort trap: 6

Environment Details

-karma.config.js: // Karma configuration file, see link for more information // https://karma-runner.github.io/0.13/config/configuration-file.html const path = require('path');

module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular/cli'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), require('@angular/cli/plugins/karma'), require('karma-coverage'), require('karma-junit-reporter'), require('karma-phantomjs-launcher'), require('phantomjs-prebuilt') ], client: { clearContext: false }, files: [ {pattern: './src/test.ts', watched: false},

],
preprocessors: {
  './src/test.ts': ['@angular/cli', 'coverage']
},
mime: {
  'text/x-typescript': ['ts', 'tsx']
},
reporters: ['progress','kjhtml', 'junit','coverage','coverage-istanbul'],

junitReporter: {
  outputDir: './reports/',
  outputFile: 'junit-result.xml',
  useBrowserName: false
},

coverageReporter: {
  dir: './reports/',
  watermarks: {
    statements: [50, 75],
    functions: [50, 75],
    branches: [50, 75],
    lines: [50, 75]
  },
  reporters: [
    {
      type: 'cobertura',
      subdir: '.',
      file: 'cobertura.xml'
    },
    {
      type: 'lcovonly',
      subdir: 'lcov'
    }
  ]
},

coverageIstanbulReporter: {

  reports: ['html', 'text-summary'],

  dir: path.join(__dirname, './reports/'),

  fixWebpackSourcePaths: true,

  'report-config': {

    html: {
      subdir: 'html'
    }

  },

  thresholds: {
    statements: [50, 75],
    functions: [50, 75],
    branches: [50, 75],
    lines: [50, 75]
  }

},

angularCli: {
  environment: 'dev'
},

browserNoActivityTimeout: 100000,
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['PhantomJS'],
singleRun: true

}); };

ben-kn-app commented 7 years ago

Same error here, did you found a solution?

Izhaki commented 6 years ago

Same issue here. Related: https://github.com/karma-runner/karma/issues/1868

piacenti commented 4 years ago

With webpack if it works for me if I use a more simplified form of sourcemaps or turn them off altogether