backstage icon indicating copy to clipboard operation
backstage copied to clipboard

The branch coverage couldn't reach the 100%.

Open SerenaIce opened this issue 5 years ago • 6 comments

I found that the branch coverage could not reach 100% in the report. And it shows the IF ELSE reminder at the very first beginning, although there's no other branches in the current tested file. Please refer to the snapshots below.

  1. Coverage_4

  2. Coverage_1

  3. Coverage_3

I was wondering whether it's caused by importing the @sucrase/jest-plugin which replaced the original coverage provider.

Backstage release-2021-7-29.

SerenaIce avatar Aug 16 '21 06:08 SerenaIce

Thanks, @fshowalter.

SerenaIce avatar Aug 18 '21 05:08 SerenaIce

Poked around at the coverage of some of our tests, and I believe what's going on here is that sourcemaps for the coverage are working just fine. The stuff we're seeing at the top of the files are most likely helpers added by sucrase, which are just functions for handling things like optional chaining. We'll eventually be able to skip transpiling these, but it might be a while, but tbh I think it's the way forward.

I would assume that there actually is a lack of coverage though, although it might not always be the case. Do check if you for example can bump it up by covering some more cases in an optional chaining for example. It's obviously not optimal the way it works atm, but I'm also having a hard time figuring out what we can do instead other than waiting for transpilation to no longer be needed.

I'm assuming the close was by mistake 😅

Rugvip avatar Aug 18 '21 09:08 Rugvip

Agree on both fronts. It's the helpers and optional chaining can be an example an issue. BUT, that's hardly apparent from the coverage output vs. ts-jest where it will highlight the optional chaining line and indicate it's partially covered. This is a tough one, and likely needs to be resolved between sucrase and istanbul.

fshowalter avatar Aug 18 '21 12:08 fshowalter

@Rugvip , we just switch back to js-test to solve this coverage issue atm. But you're right, we should find the way to solve this problem fundamentally.

SerenaIce avatar Aug 19 '21 00:08 SerenaIce

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '21 02:10 stale[bot]

@SerenaIce found a more proper fix to this in #8173, switching the coverageProvider to 'v8' seems to yield much better results, especially for the branch coverage.

Rugvip avatar Nov 20 '21 10:11 Rugvip