How coveraje works
coveraje inspects the javascript source code and injects calls to internal helper functions. The injected code is used internal only. No modification of the original source code is needed.
E.g. the code
test();
var x = test2();
is recreated as (simplified for demonstration)
visit(0, 4);
test();
var x = visitAndReturn(test2(), 16, 20);
where visit
and visitAndReturn
are the helper funtions. The numbers are the position in the original file.
With this, coveraje is able to show which parts are visited zero times, once, or more than once.
There are special cases for branches and function parameters (and there will be more in the future), but the process is always the same.