swc-plugin-coverage-instrument icon indicating copy to clipboard operation
swc-plugin-coverage-instrument copied to clipboard

Incomplete instrumentation for nested functions

Open astik opened this issue 2 years ago • 2 comments

Hi, First of all, thanks for your plugin, it help us greatly in our tooling process in order to pass our quality gate ❤️

We have found a very tricky issue when defining nested function / callback and chaining with boolean operator.

For example:

data?.map((stat) => {
  console.log(stat); <-- no instrumentation :'(
  return "bla"; <-- no instrumentation :'(
}) || [];

(data || []).map((stat) => {
  console.log(stat);  <-- instrumentation!
  return "bla"; <-- instrumentation!
});

Doing the instrumentation with NYC, i have no issue, everything is covered.

Repo for reproducing the issue on a minimal scope: https://github.com/astik/swc-plugin-coverage-instrument-issue-224.

astik avatar Aug 03 '23 17:08 astik

Probably there are some uncovered paths in the visitor. I may not have time to look into this, but happy to accept a PR with corresponding test case.

kwonoj avatar Aug 04 '23 19:08 kwonoj

Would have love to help this project, but i've got no knowledge about Rust :'(

astik avatar Aug 05 '23 13:08 astik

I think this is adquetely resolved with latest release.

kwonoj avatar Jul 04 '24 05:07 kwonoj