You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, the previous version in which this bug was not present was: Angular 12
Description
The coverage produced when running ng test --code-coverage is incorrect, it is missing branches that were previously counted. This applies to if that do not have an else: these used to be counted as two branches, and they are now counted as one. This artificially increases branch coverage.
馃敩 Minimal Reproduction
Starting from a minimal reproduction repository (ng new), make the following changes:
Add src/foo.ts. Note that this function contains two branches to cover: the if, and the (non-explicitly written) else.
export function foo(n: number) {
if (n % 2 === 0) {
console.log('hello');
}
}
It turned out to be pretty complex to find the root cause. After spending most of yesterday afternoon and today's morning I was able to locate the source of the issue. It turns out that this is caused by this change in istanbul-lib-instrument which is causing incorrect branch coverage for implicit else.
I opened an issue in their repo with a minimal reproduction. I suggest that you subscribe to that issue.
I am going to close this issue, as is not actionable from our end since we don't control which version of istanbul-lib-instrument is used because this is a transitive dependency.
馃悶 Bug report
Command (mark with an
x
)Is this a regression?
Yes, the previous version in which this bug was not present was: Angular 12Description
The coverage produced when running
ng test --code-coverage
is incorrect, it is missing branches that were previously counted. This applies toif
that do not have anelse
: these used to be counted as two branches, and they are now counted as one. This artificially increases branch coverage.馃敩 Minimal Reproduction
Starting from a minimal reproduction repository (
ng new
), make the following changes:src/foo.ts
. Note that this function contains two branches to cover: the if, and the (non-explicitly written) else.src/foo.spec.ts
:foo.spec.ts
insrc/test.ts
:npx ng test --code-coverage
For comparison, downgrading to Angular 12 and to Typescript 4.3.5 results in the correct coverage report, which is:
馃實 Your Environment
Everything comes from the default app when running
ng new
The text was updated successfully, but these errors were encountered: