kwonoj/swc-plugin-coverage-instrument

Functions in conditionals are not included in the coverage report

Closed this issue · 1 comments

This is a minimal case for reproduction

let i = 0;

const t = true && {
    renderFn: () => (
        i++
    ),
}

t.renderFn();

babel result:

...
var i = (cov_1a1nkg2pc4().s[0]++, 0);
var t = (cov_1a1nkg2pc4().s[1]++, (cov_1a1nkg2pc4().b[0][0]++, true) && (cov_1a1nkg2pc4().b[0][1]++, {
    renderFn: function renderFn() {
        cov_1a1nkg2pc4().f[0]++;           <<< HERE
        cov_1a1nkg2pc4().s[2]++;
        return i++;
    }
}));
cov_1a1nkg2pc4().s[3]++;
t.renderFn();
...

this plugin result:

...
cov_1387234055988355335();
cov_1387234055988355335().s[1]++;
var t = (cov_1387234055988355335().b[0][0]++, true) && (cov_1387234055988355335().b[0][1]++, {
    renderFn: function() {
        return i++;                         <<< HERE
    }
});
cov_1387234055988355335().s[2]++;
t.renderFn();
...

Similar to #224 (comment), I guess there's some missing coverage. Happy to accept PR.