Mocking a Function without Jest
Learn to manually mock a function without employing Jest’s mocking features.
We'll cover the following...
Starter project
The project for this lesson contains a Hello
component that renders “Hello” and a user’s name. The user’s name is retrieved from a web API request. The project also contains a test to verify that the message includes the user’s name.
A copy of the project is in the code widget below. Clicking the “Run” button executes the tests.
export default "test-file-stub";
Starter project
Run the test.
Does the test pass or fail? Why?
In this lesson, we’ll resolve the failing test by providing an alternate implementation of the getUser
function.
Manually
...Access this course and 1400+ top-rated courses and projects.