karma-coverage
karma-coverage copied to clipboard
Code coverage: how to cover code in <script> tag in html files?
Hello,
I am working with lots of html files, each of them containing
I am testing these, and they are working correctly.
But, the code coverage is reporting nothing about theses files. And I would like them to do so.
Html files are about (they are polymerjs component):
<dom-module name="epc-catched-network-request">
<script>
.. code to be tested against code-coverage ..
</script>
</dom-module>
In my karma.conf.js, I have this code:
...
preprocessors: {
'framework/*.js': [ 'coverage' ],
'framework/*.html': [ 'coverage' ],
'framework/!(bower_components)/**/*.js': [ 'coverage' ],
'framework/!(bower_components)/**/*.html': [ 'coverage' ],
},
...
Any clue on how to have some code coverage report taking code in tags?
+1
I hope you guys realize that coverage capability is not part of Karma. Whatever coverage you get is handled by a completely separate library - Istanbul (NYC).
Some news of upstream work...
Istanbul does not include html in code coverage upto now. A bug is open here: https://github.com/gotwarlost/istanbul/issues/432
In the comments, we can see that there is a cool package targetted to that goal here: https://github.com/apowers313/html-script-hook
Multiple directions are possible from there:
- Istanbul includes the package in its core functionnalities
- Karma includes the package in its runtime
- We publish a plugin to include the functionnalities of html-script-hook into karma
AFAIK, I think the third option (the plugin) would be the fastest way to include that in karma. But does anyone know how to make that?