3 ms·
How is it able to test code coverage in the browser? Can JavaScript step through JavaScript?
by mg 2y ago
How is it able to test code coverage in the browser?
Can JavaScript step through JavaScript?
- podgorniy 2y agoI'll speculate. They add extra lines (most probably via AST, not lines of chars) to the code which register if code run. Can't confirm that with code or anything. I saw similar techniqies in test coverage tools.
- mg 2y agoTrue, if you rewrite the code, then that would even work via a simple injection of _cover(123); after each line, where 123 is the line number. Could be a fun project to write a bookmarklet that does this to the current page, then lets you use it and then tells you which parts of the code have not been used.