Node.js / NestJS

Unit Testing

Jest, test suites, mocking, spies, test coverage, testing providers, controllers

20 면접 질문·
Junior
1

What is the role of the describe() function in Jest?

답변

The describe() function groups multiple related tests together in a test suite. It improves readability by organizing tests by feature or component. Each describe() can contain multiple it() or test() to describe individual behaviors.

2

What is the difference between it() and test() in Jest?

답변

There is no functional difference between it() and test() in Jest. They are two aliases that do exactly the same thing. The choice between them is purely a matter of style and writing preference. Some prefer it() for a more natural BDD syntax, others prefer test() for clarity.

3

Which Jest matcher should be used to verify that a value is strictly equal to another?

답변

The toBe() matcher checks strict equality using the === operator in JavaScript. It compares references for objects, meaning two objects with the same content but different references won't be equal. To compare object content, use toEqual() instead.

4

What is the difference between toEqual() and toStrictEqual()?

5

How to execute code before each test in a Jest suite?

+17 면접 질문

다음 면접을 위해 Node.js / NestJS을 마스터하세요

모든 질문, flashcards, 기술 테스트, 코드 리뷰 연습, 면접 시뮬레이터에 접근하세요.

무료로 시작하기