Unit Test
A fast, isolated test of one unit of behavior with its collaborators replaced.
A unit test exercises a small piece of behavior in isolation, with anything slow or external replaced by a Test Double. Its virtues are speed and precision: thousands run in seconds, and a failure names a narrow location.
The perennial argument is about what counts as a unit. Taken as "one function", the result is a suite bound to internal structure, which breaks on every refactor and prevents the change it was supposed to protect. Taken as "one behavior, at whatever boundary is stable", the suite survives implementation changes and stays useful. The second reading is the one that ages well.
Unit tests are best suited to pure logic: reducers, adapters, parsers, calculations, anything whose inputs and outputs are values. They are poorly suited to anything whose correctness depends on a real environment — layout, focus, styling, browser behavior — where the double diverges from reality and the test passes while the product is broken.
There is also an environmental cost worth knowing about. A unit test that imports a user-interface module drags that module into the unit environment, which can distort coverage measurement for files nobody touched. Importing a value from the package that owns it, rather than through a component barrel, avoids the whole class of problem. See Code Coverage and Tree Shaking.
See also8
Integration Test
A test exercising several components together, through real interfaces rather than doubles.
Testing & Verification17 connections
Test-Driven Development
Writing a failing test first, making it pass, then improving the code with the test as a net.
Testing & Verification12 connections
Component Story
An isolated rendered instance of a component, usable as documentation, a workbench, and a test.
Testing & Verification17 connections
Test Fixture
The prepared data or state a test runs against.
Testing & Verification16 connections
Regression
A previously working behavior that a change has broken.
Method23 connections
Module Graph
The directed graph of imports that decides what code ends up where.
Web Platform22 connections
Property-Based Testing
Asserting a general property that should hold for all inputs, then letting the framework generate many random inputs to try to break it.
Testing & Verification11 connections
Test Isolation
The property that each test passes or fails on its own, regardless of which other tests run, in what order, or in parallel.
Testing & Verification20 connections
Linked from21
- Binary SearchComputation & Algorithms
Finding a value in a sorted range by repeatedly discarding half of it.
- Code CoverageTesting & Verification
The proportion of code executed by a test suite — a map of what is untested, not a measure of quality.
- Contract TestingTesting & Verification
Verifying that a service and its consumer agree on an interface's shape, without either side needing the other running to test against.
- Dependency InjectionTesting & Verification
Passing a component the things it depends on instead of letting it build them itself, which decouples code and makes it easy to substitute fakes in tests.
- End-to-End TestTesting & Verification
A test that drives the whole running system the way a user would, from the interface down through every real dependency, buying the most confidence at the highest cost.
- Headless BrowserTesting & Verification
A real browser driven programmatically without a visible window.
- Integration TestTesting & Verification
A test exercising several components together, through real interfaces rather than doubles.
- MonadComputation & Algorithms
A wrapper type with a way to lift a value in and a way to chain functions that return more wrappers.
- Mutation TestingTesting & Verification
A test-of-tests that injects small bugs into code and checks whether the existing suite catches them, exposing tests that assert nothing.
- Parameterized TestTesting & Verification
Running one test body against a table of inputs and expected outputs, so each case is a single readable row and each failure is reported on its own.
- Property-Based TestingTesting & Verification
Asserting a general property that should hold for all inputs, then letting the framework generate many random inputs to try to break it.
- Pure FunctionComputation & Algorithms
A function whose output depends only on its input and which causes no observable effect outside itself.
- Regression TestingTesting & Verification
Rerunning existing tests after every change to confirm that what used to work still works, how the suite grows one fixed bug at a time, and how teams keep it fast enough to run.
- Responsive BreakpointDesign & Interface
A viewport width at which a layout changes, and the assumptions that come with it.
- Smoke TestTesting & Verification
A fast, shallow check that a build isn't catastrophically broken, run before investing in a deeper test pass.
- Test Data BuilderTesting & Verification
Helpers that build valid test objects from sensible defaults so each test states only the fields it cares about, and the Object Mother pattern they grew out of.
- Test DoubleTesting & Verification
A stand-in for a real dependency during a test — and the ways a stand-in can lie.
- Test FixtureTesting & Verification
The prepared data or state a test runs against.
- Test-Driven DevelopmentTesting & Verification
Writing a failing test first, making it pass, then improving the code with the test as a net.
- Tree ShakingWeb Platform
Statically removing exports that nothing imports, shrinking the shipped bundle.
- Type SystemTesting & Verification
The rules a language uses to classify values and reject operations that don't fit, checked before the program runs or as it runs, and the cheapest form of verification most programmers use every day.