Back to Tech Interviews
Jest JavaScript Testing Interview
Curated 20+ questions covering Jest matchers, async code, snapshot updates, lifecycle hooks, mock utilities, and config options.
Total: 20 QuestionsLearned: 0 / 20 (0%)
Difficulty Filters
Tools & Options
Showing 20 of 20 questions
Beginner
What is Jest, and what are its key advantages?
Beginner
Explain the difference between `toBe()` and `toEqual()` matchers in Jest.
Intermediate
How do you test asynchronous code in Jest?
Intermediate
What is Snapshot Testing, and when should you use it?
Advanced
Explain the difference between `jest.fn()`, `jest.spyOn()`, and `jest.mock()`.
Intermediate
How do you mock an external module (e.g., `axios`) in Jest?
Beginner
What are Jest setup and teardown lifecycle hooks?
Beginner
Explain how to check if a mock function was called.
Intermediate
What is `jest.useFakeTimers()`, and when is it used?
Intermediate
What is a mock implementation vs a mock return value?
Beginner
How do you test that a function throws an error in Jest?
Beginner
What is the Jest configuration file, and what is its default name?
Advanced
What is the difference between `jest.runOnlyPendingTimers()` and `jest.runAllTimers()`?
Beginner
What is the difference between `test()` and `describe()` in Jest?
Advanced
Explain `jest.clearMocks()`, `jest.resetMocks()`, and `jest.restoreMocks()`.
Intermediate
What is the difference between Jest's `node` and `jsdom` test environments?
Intermediate
Explain code coverage configuration in Jest.
Beginner
How do you run a specific single test file in Jest?
Advanced
What is the `mockFn.mock.calls` property?
Advanced
