karma-runner / karma

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

TeamCity code coverage plugin with Karma >=0.12.26 reports zero coverage #1255

Open parautenbach opened 9 years ago

parautenbach commented 9 years ago

Using Karma 0.12.26, 27 and 28 with the dependencies below seem to break karma-coverage, in the sense that the TeamCity plugin does not report correct coverage values (it's all zero). The last version to work fine with the dependencies below is Karma 0.12.25.

> web-lib@0.0.0-0 posttest-teamcity /private/tmp/web-lib/src
> istanbul report html teamcity; ./node_modules/.bin/istanbul check-coverage

\
##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageB' value='100']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageM' value='100']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='0']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='0']
##teamcity[buildStatisticValue key='CodeCoverageL' value='100']
##teamcity[blockClosed name='Code Coverage Summary']
Done

Here is a partial package.json:

      "dependencies": {
          "bower": "~1.3.9",
          "uglify-js": "latest",
          "clean-css": "latest"
      },
      "devDependencies": {
          "angular-jsdoc": "0.1.1",
          "chai": "1.9.1",
          "chai-fuzzy": "1.4.0",
          "istanbul": "0.3.0",
          "jscs": "1.5.9",
          "jshint": "2.5.2",
          "jshint-html-reporter": "0.1.3",
          "jscpd": "0.3.2",
          "jsdoc": "~3.3.0",
          "karma": "0.12.26",
          "karma-cli": "0.0.4",
          "karma-mocha": "0.1.7",
          "karma-coverage": "0.2.7",
          "karma-phantomjs-launcher": "0.1.4",
          "karma-teamcity-reporter": "0.1.2",
          "karma-spec-reporter": "0.0.13"
      },
      "scripts": {
          "postinstall": "bower install",
          "clean": "rm -fR coverage doc cpd.xml jscs.xml jshint.xml jshint.html *.log logs/*.log",
          "pretest": "npm run-script clean && npm run-script style && npm run-script lint",
          "test": "./node_modules/.bin/karma start test/karma.conf.js",
          "test-teamcity": "./node_modules/.bin/karma start test/karma.conf.js --reporters coverage --reporters teamcity",
          "posttest": "./node_modules/.bin/istanbul report text html; ./node_modules/.bin/istanbul check-coverage",
          "posttest-teamcity": "./node_modules/.bin/istanbul report html teamcity; ./node_modules/.bin/istanbul check-coverage",
          "style": "./node_modules/.bin/jscs *",
          "style-teamcity": "./node_modules/.bin/jscs --reporter checkstyle * >jscs.xml",
          "lint": "./node_modules/.bin/jshint --verbose .",
          "lint-html": "./node_modules/.bin/jshint --reporter ./node_modules/jshint-html-reporter/reporter.js --verbose . ./bin/www.js >jshint.html; open jshi    nt.html",
          "lint-teamcity": "./node_modules/.bin/jshint --reporter checkstyle --verbose . >jshint.xml",
          "cpd": "./node_modules/.bin/jscpd",
          "doc": "./node_modules/.bin/jsdoc -c .jsdoc.json ../README.md .",
          "minify": "./node_modules/.bin/uglifyjs ./constants.js ./directives.js ./directives/*.js --output praelexis-web-lib/web-lib.min.js"
      },

I've also discovered that using 0.12.26 and up and removing the --reporters teamcity option from the test-teamcity run script, the coverage would be correct, but no test service messages for TeamCity will be generated.

parautenbach commented 9 years ago

It seems like this commit could be related to the issue.