Question · JavaScript and React course · Module 13: Testing React

jest.mock() - replacing modules

What does jest.mock('./api/missionApi') do in a test?

Answer options

  • It imports the real module and runs it in debug mode
  • It creates a copy of the module in a temporary folder
  • It compiles the module to WebAssembly for faster execution
  • It replaces the whole module with an automatically generated mock

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