DEV Community

Insight Lighthouse
Insight Lighthouse

Posted on

A Script Tells Me What To Test

When using Jest, I like to bump the global coverage threshold. Yesterday I was excited to bump the numbers in my suggest-test repository.

coverageThreshold: {
  global: {
    branches: 67,
    functions: 33,
    lines: 38,
    statements: 38,
  },
},
Enter fullscreen mode Exit fullscreen mode

After testing 4 not large units, my branch coverage was much higher than everything else. The reason this made me happy is that it was the result of using my own suggest-test tool on itself. The includeStatements command line argument had honed in on conditionals for me.

suggest-test --includeTested=false --includeStatements=false
Enter fullscreen mode Exit fullscreen mode

I think it's a mistake that so many focus on statements/lines and not more on conditionals/branches. Conditionals are where most of the business logic resides. And it's easy to write half baked tests to boost statement coverage without really testing much.

And while it's still only a release candidate, feel free to try out my @clowd/suggest-test NPM package.

Top comments (0)