Mocking a Function without Jest

Learn to manually mock a function without employing Jest’s mocking features.

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.

Get hands-on with 1400+ tech skills courses.