Code coverage using Google Chrome is not accurate

Viewed 26

I'm using Google Chrome Code coverage tool to extract only the CSS and JS code that is used on the pages but it is not working as expected. The CSS is not considering the @media queries even if I resize the page in all the possible devices: enter image description here

I also tested the Code coverage tool with jQuery javascript and it also extract only internal functions used, but if you remove the code that is not marked as not used it will not work because they are function and variable declarations that are needed.

Is there another tool to do it easily?

1 Answers

Post your test scripts that are being used to test code coverage. You definitely cannot remove @media and have it still work even though it's marked as "not used". CSS does not respond in that manner. That portion is needed to make the style for the page.

I also use InteliJ for code coverage, I think it shows better metrics on the test and they are exportable to HTML.

Maybe try this to find unused CSS: https://unused-css.com/

Related