karma-runner / karma-coverage

A Karma plugin. Generate code coverage.
MIT License
770 stars 247 forks source link

Code coverage: how to cover code in <script> tag in html files? #277

Open jehon opened 7 years ago

jehon commented 7 years ago

Hello,

I am working with lots of html files, each of them containing tags?

jscharett commented 7 years ago

+1

stsvilik commented 7 years ago

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).

jehon commented 7 years ago

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:

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?