karma-runner / karma-runner/karma
TeamCity code coverage plugin with Karma >=0.12.26 reports zero coverage
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
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.
``` sh
> 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`:
``` 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.
Contributor guide
Research direction
Start with the test-teamcity script in package.json and test/karma.conf.js, using the listed Karma, karma-coverage, and karma-teamcity-reporter versions. Reproduce the difference between Karma 0.12.25 and 0.12.26 or later, then verify that coverage values and TeamCity service messages are both generated correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100