DEV Community

Insight Lighthouse
Insight Lighthouse

Posted on

3 2

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.

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay