Unit Test
A small, isolated test that verifies a single function or module behaves correctly.
A unit test checks one piece of logic in isolation. You give a function specific inputs and assert it returns the expected output. If someone later changes that function and breaks the behavior, the test fails immediately.
Unit tests are fast (milliseconds each), easy to write, and form the foundation of a test suite. Tools like Vitest, Jest, and the built-in Node test runner make it simple to write and run them. A typical test file sits next to the code it tests and covers the happy path, edge cases, and error conditions.
For vibe coders, unit tests are your safety net when iterating with AI. You can ask AI to write a function, then write tests to verify it works. If a future prompt changes the function, the tests catch regressions. AI tools are also excellent at generating unit tests from existing code.
Related Courses
Links open the course details directly on the Courses page.