Unit Test Purpose
Question
What is a unit test?
Hint
Unit tests are fast, isolated, and focused.
Explanation
A unit test verifies a single unit of code (function, method, class) in isolation, without external dependencies. Characteristics: fast (milliseconds), isolated (no network, database, filesystem), focused (one behavior per test), deterministic (same result every time). Unit tests use mocks/stubs for dependencies. They form the base of the test pyramid (most numerous). Example: testing a calculateTax function with known inputs and expected outputs. Frameworks: Jest, Mocha, Vitest, pytest.
Related Resources
Related Lessons
- Unit Testing
Learn unit tests.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.