Mistake: Missing Assertion
Find the Mistake Beginner
Question
What is wrong with this test?
Code
test('addition', () => {
const result = 1 + 1;
});
Hint
The test computes a value but never checks it.
Explanation
The test has no assertion — it computes 1 + 1 but never verifies the result. A test without an assertion will always pass, even if the code is wrong. The fix is to add expect(result).toBe(2); to actually verify the behavior.
Related Resources
Related Lessons
- Jest Basics
Getting started with Jest.
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.