Loading
Code that automatically checks whether a small piece of your code works correctly.
A test that exercises a single function or module in isolation. Follows the Arrange/Act/Assert pattern: set up inputs, call the function, check the output. Frameworks like Vitest and Jest discover and run tests automatically.
Unit tests verify behavior at the smallest granularity — typically one function per test case. They should be fast (no I/O), deterministic (same result every run), and independent (no shared state between tests). Test doubles (mocks, stubs, spies) isolate the unit from dependencies.