Fill: toBeDefined
Fill in the Blank Easy
Question
Fill in the blank to check the value is defined:
Code
test('is defined', () => {
expect(42).___();
});
Hint
The matcher checks the value is not undefined.
Explanation
The correct answer is toBeDefined. This matcher checks that the received value is not undefined. Since 42 is a defined value, the assertion passes. This is useful for verifying that functions return a value.
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.