Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

includeAllSources does not work as expected #166

Closed
schalkneethling opened this issue Jul 8, 2015 · 6 comments · Fixed by #176
Closed

includeAllSources does not work as expected #166

schalkneethling opened this issue Jul 8, 2015 · 6 comments · Fixed by #176

Comments

@schalkneethling
Copy link

From the documentation:

"You can opt to include all sources files, as indicated by the coverage preprocessor, in your code coverage data, even if there are no tests covering them."

https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md#includeallsources

However, with the following karma.conf.js

https://gist.github.com/schalkneethling/ccb6d61ef84e5a2e0107

When I run my grunt test target, the coverage report only shows the JS for which tests exist and nothing else. This leads me to believe that the includeAllSources flag does not work as advertised.

I have read the issue here #11 logged almost two years ago, and the resulting PR, #76

Both are still open however, and I am wondering whether the addition of includeAllSources superseded the above? In either case, having full test coverage for all JS, even is there are no tests for it, is what I believe most (perhaps even all) people would want and need.

It would be great if this issue could be resolved soon. Thank you.

@stephanebachelier
Copy link

I confirm this problem still exists.

@emmenko
Copy link

emmenko commented Aug 18, 2015

Yep 👍

EDIT: using isparta-loader

@terussell85
Copy link

There appears to be a bug in preprocessor.js line 126 (https://github.com/karma-runner/karma-coverage/blob/master/lib/preprocessor.js#L126), in that coverageObjRegex is stateful. So coverageObjRegex.lastIndex will be incorrect for every other time that coverageObjRegex.exec(instrumentedCode) is run.

I think this may solve the missing files from includeAllSources.

@djmc
Copy link

djmc commented Sep 8, 2015

I have found that the includeAllSources leads to an inconsistent code coverage percentage (it varies wildly from test run to test run), and it appears that @terussell85's pull request (#176) does fix this in our case. The last comment on it says that it will be merged tomorrow, 16 days ago. I was wondering what the next steps would be for that PR to be merged to help move it along?

@shaikhspear16
Copy link

facing the same issue. any help ? also trying to use karma-coverage-allsources https://www.npmjs.com/package/karma-coverage-allsources does not help. Apparently I get an error "could not load coverage-allsources it is not registered, Perhaps are you missing some plugin".

@kopach
Copy link

kopach commented Feb 29, 2020

Hi there. For anyone still interested in this topic, Here is a tool, which helps to add untested files to coverage report. It works fine with both JavaScript and TypeScript files. https://github.com/kopach/karma-sabarivka-reporter
Karma has limitation in detecting all source files, in case we pass only 1 file as starting point to our tests. This tool overcomes this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants