Test Coverage Calculator
Enter covered and total counts for lines, branches, functions, and statements.
See your coverage percentages, pass/fail status against thresholds, and get a
ready-to-use jest.config.js /
vitest.config.ts threshold snippet.
Coverage Counts
Thresholds (%)
Results
Config Snippet
Frequently Asked Questions
What are the four standard code coverage metrics?▼
Line coverage: percentage of source lines executed during tests. Branch coverage: percentage of decision paths taken (both true/false for if/else). Function coverage: percentage of functions/methods that were called. Statement coverage: percentage of individual statements executed (finer-grained than line coverage). Branch coverage is generally the most meaningful because it catches logic gaps that line coverage misses.
What coverage percentage should I aim for?▼
80% is the widely accepted industry standard for most production projects. Google's engineering guidelines suggest 60% as acceptable, 75% as good, and 90%+ as exemplary. However, raw percentages can be misleading — 100% line coverage doesn't guarantee correct behavior. Aim for 80% as a starting point, focus on critical paths, and use meaningful assertions rather than just maximizing coverage numbers.
How do I input lines, branches, and functions for calculation?▼
You need two numbers for each metric: total (how many exist in your codebase) and covered (how many were executed during your test suite). Jest and Vitest print these numbers when you run with --coverage: e.g., 'Lines: 450/600' means 450 covered out of 600 total. Enter these numbers directly into the calculator to see your percentage and pass/fail status.
How do I set coverage thresholds in Jest or Vitest?▼
In jest.config.js: add coverageThreshold: { global: { lines: 80, functions: 80, branches: 70, statements: 80 } }. In vitest.config.ts: add coverage: { thresholds: { lines: 80, functions: 80, branches: 70 } } inside the test block. The build will fail if any metric falls below its threshold — perfect for CI enforcement. This calculator generates the config snippet based on your entered values.
Why is branch coverage often lower than line coverage?▼
Because a line can be 'covered' even if only one branch was taken. For example, if (condition) { doA() } else { doB() } — if your tests only trigger the true branch, line coverage shows the if-statement as covered, but branch coverage shows 50% (one of two paths). Branch coverage is stricter and catches gaps in conditional logic that line coverage misses.
What is the difference between v8 and istanbul coverage providers?▼
v8 uses Node.js's built-in V8 engine coverage data — it's fast, no code instrumentation needed, and works with source maps. Istanbul instruments your code by injecting counters at compile time — it's slower but generally more accurate for complex code, especially around branches in minified or transpiled code. For most TypeScript projects, v8 is sufficient and recommended. Use istanbul if you notice v8 misreporting edge cases.
Related Products
on GumroadDevToolkit Starter Kit
A ready-to-deploy developer tools website with 12 built-in tools. Astro + Preact + Tailwind. Deploy to Cloudflare Pages for free. Built-in SEO, dark mode, and ad-ready layout.
Buy on Gumroad →TypeScript Quick Reference Toolkit
5 practical reference files for TypeScript developers: cheatsheet, TS vs JS comparison, 20 utility types with real examples, tsconfig best practices template, and 15 common mistakes guide. Print it. Keep it on your desk.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
Vitest Configuration Generator
Generate a complete vitest.config.ts visually. Configure test environment (node/jsdom/happy-dom), coverage provider, reporters, thresholds, and path aliases.
Open free tool →
Jest Coverage Config Generator
Generate Jest configuration with coverage thresholds, reporters, and collectCoverageFrom patterns. Set line, function, branch, and statement thresholds.
Open free tool →
Jest Testing Framework Guide
Complete guide to Jest JavaScript testing framework. Learn describe/it/expect, mocking, snapshot testing, async tests, coverage, and best practices for unit and integration testing.
Open free tool →
More Free Tools
Related Articles
Modern JavaScript Testing 2026: Vitest vs Jest vs Playwright
Complete guide to JavaScript testing in 2026. Compare Vitest vs Jest for unit tests, Playwright vs Cypress for E2E, component testing, coverage tools, and CI/CD integration.
MSW 2.0: The Best Way to Mock APIs in Frontend Tests
A complete guide to Mock Service Worker (MSW) 2.0 — setup, request handlers, Vitest and Jest integration, Storybook mocking, and best practices for realistic API mocking in frontend tests.
Vitest: The Fast Unit Testing Framework for Vite Projects - 2026 Guide
Complete guide to Vitest in 2026: setup, configuration, mocking, coverage, watch mode, and a detailed comparison with Jest to help you decide which testing framework fits your project.
Vitest vs Jest vs Mocha: Complete Testing Framework Comparison 2026
A comprehensive comparison of Vitest, Jest, and Mocha for JavaScript and TypeScript projects in 2026. Covers speed benchmarks, configuration, TypeScript support, mocking, code coverage, and migration strategies.
Vitest vs Jest 2026: Modern Testing Comparison
Comprehensive comparison of Vitest vs Jest in 2026: speed benchmarks, ESM support, migration guide, snapshot testing, mocking, watch mode, and coverage reporting.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$9/mo after trial · Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →