Creating a Manual Shared Module Mock

Learn to manually mock a whole module shared across test files.

Starter project

The project for this lesson is similar to the one in the last lesson. It contains a test to verify a Hello component renders a user’s name and a test to verify a YouAre component renders a user’s role. The components have a dependency on a common data.js module. The tests on the components are in different files, and the tests currently fail.

A copy of the project is in the code widget below. Clicking the “Run” button executes the tests.

Get hands-on with 1200+ tech skills courses.