Unit & Component Testing
Fast feedback on individual functions and components, in milliseconds.
What this category is really about
Unit tests are the base of the pyramid: cheap to write, near-instant to run, and precise about what broke. Component tests sit just above, rendering a single UI component in isolation and asserting on what a user would see.
Choice here is mostly determined by your language and build tooling. The interesting decision is not which assertion library but how much of your stack you mock — over-mocking produces suites that pass while production burns.
What to evaluate
Watch-mode speed
Sub-second re-runs on save are the entire point. Anything slower and developers stop running tests locally.
Build-tool alignment
A runner that shares your bundler's transform pipeline avoids a second, divergent config to maintain.
Coverage reporting
Native coverage that plugs into your CI's quality gate, rather than a bolted-on second tool.
Mocking ergonomics
Module mocking, timers, and network interception should be first-class, not community plugins.
Common mistakes
- Chasing a coverage percentage instead of covering the risky code.
- Mocking the thing you are actually trying to test.
- Writing component tests that assert on implementation details (class names, internal state) and break on every refactor.
17 tools built for this
Sorted by how widely adopted they are, not by preference. Tick the compare boxes to put two or more side by side.
Jest
The JavaScript testing incumbent: batteries included, snapshots, huge ecosystem.
JUnit 5
The Java testing standard, rebuilt with extensions and parameterised tests.
PHPUnit
The PHP testing standard, integrated into every major PHP framework.
pytest
The de facto Python testing framework: fixtures, parametrisation, plugins.
Storybook
Build components in isolation, then test the stories you already wrote.
Testing Library
Query the DOM the way a user would, not the way the framework does.
Vitest
Vite-native test runner with instant watch mode and a Jest-compatible API.
xUnit.net
The modern .NET testing framework, and the one Microsoft's templates default to.
Mocha
Minimal, unopinionated Node.js test runner you assemble to taste.
NUnit
The long-standing .NET test framework with the richest assertion set.
Pest
A friendlier front end for PHPUnit with a function-based, expressive API.
RSpec
Ruby's behaviour-driven testing framework with an exceptionally readable DSL.
TestNG
Java test framework built for suite configuration, grouping and data providers.
unittest
Python's standard-library xUnit framework. Always there, never exciting.
AVA
Concurrent Node.js test runner that isolates every file in its own process.
Jasmine
Behaviour-driven JavaScript testing framework with no external dependencies.
node:test
Node.js's built-in test runner. Zero dependencies, already installed.
Tools that also cover this
These are built primarily for something else but handle this category as part of a broader platform — often a way to consolidate two subscriptions into one.
Cypress
E2E & UI Testing
Developer-first browser testing with an interactive runner developers actually enjoy.
Espresso
Mobile Testing
Google's native Android UI testing framework. Fast, stable, Android-only.
Mock Service Worker
Test Data & Mocks
Intercept requests at the network layer so your app code never knows it is mocked.
Testcontainers
Test Data & Mocks
Real databases and services in throwaway Docker containers, per test run.
XCUITest
Mobile Testing
Apple's native UI testing framework, built into Xcode.
Chromatic
Visual Testing
Visual testing and review built by the Storybook team, for Storybook.