Test Naming
Question
What is a good test name convention?
Hint
Good names document the expected behavior.
Explanation
Good test names describe the behavior being tested, not the implementation. Patterns: 1) "returns X when Y" — describes input and output. 2) "throws when input is invalid" — describes error case. 3) "calculates total including tax" — describes the feature. Avoid: 1) "test1", "test2" — meaningless. 2) "testAdd" — describes implementation, not behavior. 3) "works correctly" — vague. In Jest, use describe("ModuleName") + test("behavior description"). The full test path (describe + test) should read as a sentence: "MathUtils adds two positive numbers correctly". Good names serve as documentation and make failures immediately understandable.
Related Resources
Related Lessons
- Organization
Learn organization.
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.