Mocking a Module
Learn to mock a whole module using Jest.
Starter project
The project for this lesson is similar to the project in the last lesson. The difference is that the Hello
component renders the user’s role and name. A second web API call is made to get the user’s role.
The project contains a test to verify that the user’s name is rendered. The test should fail at the moment because the web API calls aren’t yet mocked.
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.