{"action":"created","issue":{"url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/244","repository_url":"https://api.github.com/repos/karma-runner/karma-coverage","labels_url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/244/labels{/name}","comments_url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/244/comments","events_url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/244/events","html_url":"https://github.com/karma-runner/karma-coverage/issues/244","id":168738356,"number":244,"title":"Karma Code Coverage","user":{"login":"branpar","id":16673275,"avatar_url":"https://avatars.githubusercontent.com/u/16673275?v=3","gravatar_id":"","url":"https://api.github.com/users/branpar","html_url":"https://github.com/branpar","followers_url":"https://api.github.com/users/branpar/followers","following_url":"https://api.github.com/users/branpar/following{/other_user}","gists_url":"https://api.github.com/users/branpar/gists{/gist_id}","starred_url":"https://api.github.com/users/branpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/branpar/subscriptions","organizations_url":"https://api.github.com/users/branpar/orgs","repos_url":"https://api.github.com/users/branpar/repos","events_url":"https://api.github.com/users/branpar/events{/privacy}","received_events_url":"https://api.github.com/users/branpar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-01T20:47:26Z","updated_at":"2016-10-21T12:09:41Z","closed_at":null,"body":"Hello,\r\n\r\nI am trying to get code coverage to work with Webpack and Karma. I'm running into MANY difficulties which are preventing my company from accurately testing the JS code. Included below is my Karma config file. \r\n\r\n```\r\nvar config = require('./gulp/config'),\r\n    karmaWebpack = require('karma-webpack'),\r\n    webpackConfig = require('./gulp/util/webpack-multi-config'),\r\n    path = require('path');\r\n\r\nvar testSrc = './scripts/tests/**/*.tests.js',\r\n    jsSrc = './scripts/**(!tests)/*.js';\r\n\r\nvar karmaConfig = {\r\n    frameworks: ['mocha', 'sinon-chai'],\r\n    files: [\r\n        testSrc,\r\n        jsSrc\r\n    ],\r\n    preprocessors: {\r\n        testSrc: ['webpack'],\r\n        jsSrc: ['webpack', 'coverage']\r\n    },\r\n    webpack: webpackConfig('test'),\r\n    singleRun: 'true',\r\n    reporters: ['spec', 'coverage'],\r\n    browsers: ['Chrome'],\r\n    coverageReporter: {\r\n        reporters: [\r\n          { type: 'text' },\r\n          { type: 'text-summary' },\r\n          { type: 'html', dir: './coverage' }\r\n        ],\r\n    },\r\n    client: {\r\n        captureConsole: false\r\n    },\r\n    specReporter: {\r\n        showSpecTiming: true \r\n    },\r\n    reportSlowerThan: 25\r\n};\r\n\r\nkarmaConfig.preprocessors[testSrc] = ['webpack'];\r\nkarmaConfig.preprocessors[jsSrc] = ['webpack', 'coverage'];\r\n\r\n\r\nmodule.exports = function (config) {\r\n    config.set(karmaConfig);\r\n}\r\n```\r\n\r\nIf I don't include the actual JS source files all the testing works out fine, but code coverage is extremely poor (it's including Webpack garbage and jQuery as part of the coverage). If I include the source files, which is proper, I get an error:\r\n\r\n```\r\nCannot find module \"../modules/[module-name]\"\r\nat scripts/tests/modules/[module-name].tests.js\r\n```\r\n\r\nI don't understand this error as the modules do exist there. It's almost like Karma and Webpack can't be used at the same time. You either have to choose to use Webpack and ES6 modules -OR- do front-end JS testing. Has anyone successfully done this? I've looked for months on this issue and tried posting several different places with no success."},"comment":{"url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/comments/255363738","html_url":"https://github.com/karma-runner/karma-coverage/issues/244#issuecomment-255363738","issue_url":"https://api.github.com/repos/karma-runner/karma-coverage/issues/244","id":255363738,"user":{"login":"pbio","id":5643249,"avatar_url":"https://avatars.githubusercontent.com/u/5643249?v=3","gravatar_id":"","url":"https://api.github.com/users/pbio","html_url":"https://github.com/pbio","followers_url":"https://api.github.com/users/pbio/followers","following_url":"https://api.github.com/users/pbio/following{/other_user}","gists_url":"https://api.github.com/users/pbio/gists{/gist_id}","starred_url":"https://api.github.com/users/pbio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbio/subscriptions","organizations_url":"https://api.github.com/users/pbio/orgs","repos_url":"https://api.github.com/users/pbio/repos","events_url":"https://api.github.com/users/pbio/events{/privacy}","received_events_url":"https://api.github.com/users/pbio/received_events","type":"User","site_admin":false},"created_at":"2016-10-21T12:09:41Z","updated_at":"2016-10-21T12:09:41Z","body":"Any update on this?  I am having the same issue. \r\nI agree with @branpar, should we be including \"./scripts/**(!tests)/*.js\" in karmaConfig.files as an entry point? It seems like we are attempting to do 2 different things at once, running karma and calculating the coverage and it's contradicting. \r\n\r\nIf I remove my component JS files from the karmaConfig.files, my unit tests can run correctly, but then my coverage report shows 0/0 100%. \r\nOn the other hand if I add my component JS files to karmaConfig.files I get the error \"a dependency to an entry point is not allowed\" and the Coverage has random percents that are definitely not correct. \r\n\r\nAlso is there anyone who actually has this working correctly? Running the tests with Karma and Webpack and also generating the coverage? \r\n\r\nWould it be better to try to separate the two processes? first run the karma tests, then figure out coverage?\r\n"}}
{"actor":{"display_login":"pbio"}}