All Jest quizzes
Intermediate30 questions60 minutes

Jest Intermediate Quiz

Explore mocking, async testing, snapshot testing, coverage, and test organization

Start the quiz

Sample questions from this quiz

A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.

1. What is mocking in Jest?

  • Replacing real implementations with test versions
  • Test doubles
  • Fake data
  • Simulation
Show answer

Answer: Replacing real implementations with test versions. Mocking replaces real implementations with controllable test versions. Isolate code under test, control dependencies, verify interactions. Use jest.fn(), jest.mock().

2. What is jest.fn()?

  • Spy function
  • Test function
  • Function mocker
  • Creates mock function
Show answer

Answer: Creates mock function. jest.fn() creates mock function. Track calls, arguments, return values. Can provide implementation. Example: const mockFn = jest.fn(); mockFn(); expect(mockFn).toHaveBeenCalled().

3. How do you check if mock was called?

  • expect(mockFn).toHaveBeenCalled()
  • mockFn.wasCalled()
  • expect(mockFn).called()
  • mockFn.called === true
Show answer

Answer: expect(mockFn).toHaveBeenCalled(). Check calls with toHaveBeenCalled(). Also: toHaveBeenCalledTimes(n), toHaveBeenCalledWith(args), toHaveBeenLastCalledWith(args).

Frequently asked questions

How many questions are in this Jest quiz?+

30 questions, with a 60-minute time limit. Every question includes a written explanation of the correct answer.

Is this Jest quiz free?+

Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.

What level is the intermediate quiz aimed at?+

Explore mocking, async testing, snapshot testing, coverage, and test organization

Can I use this to prepare for a Jest interview?+

Yes. The questions cover the topics that come up in Jest technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.

Ready to test your Jest?

30 questions, 60 minutes. Free, no sign-up.

Start now