Put in order · JavaScript and React course · Module 13: Testing React

Lifecycle of a mock in tests

Arrange the stages of a mock's lifecycle in tests in the correct order:

Items to put in order

  • beforeEach: global.fetch = jest.fn()
  • expect(fetch).toHaveBeenCalled()
  • afterEach: jest.restoreAllMocks()
  • render(<Component />)
  • fetch.mockResolvedValue(...)

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