Click in order · JavaScript and TypeScript course · Module 11: Testing with Jest

Mock Module Configuration

Arrange the steps for mocking a module in Jest:

Items to click

  • jest.mock('./alertService');
  • sendAlert.mockResolvedValue({ status: 'sent' });
  • const { sendAlert } = require('./alertService');
  • expect(sendAlert).toHaveBeenCalled();

You can check the correct answer by solving this task in the CodeWorlds game.