typescriptavanyc

Typescript edge cases mess up test coverage


I have a project set up to use the AVA test runner and the NYC coverage tool. I am sure that I have 100% test coverage.

However, because I am using typescript, it seems that the typescript compiler added a bunch of polyfills with edge cases that aren‘t covered by my tests because there is simply no way to trigger them.

How do I get NYC to compute the correct coverage?


Solution

  • It‘s me again! I figured it out!

    It turns out I was correct in my assumption that edge cases in polyfills were the cause of the problem.

    My solution was simple:

    1. Install the tslib package
    2. Set the compiler option importHelpers to true.

    This way, nyc no longer recognizes the helpers as part of my code, and I get that sweet 100% coverage badge!