Fill: mockReturnValue
Fill in the Blank Medium
Question
Fill in the blank so the mock always returns 100:
Code
const mockFn = jest.fn().___(100);
console.log(mockFn()); // 100
Hint
The method name describes setting a return value.
Explanation
The correct answer is mockReturnValue. mockReturnValue(value) configures the mock function to always return the specified value when called. Here, mockFn() will always return 100.
Related Resources
Related Lessons
- Mocking
Using mocks to isolate code.
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.