Node.js / NestJS

End-to-End Testing

Supertest, test database, fixtures, authentication in tests, API testing

20 면접 질문·
Mid-Level
1

What is an E2E (end-to-end) test in the context of NestJS?

답변

An E2E test validates the complete application flow, from HTTP request to response, through all layers (controller, service, database). Unlike unit tests that isolate a component, E2E tests verify that the integration of all components works correctly. This helps detect integration bugs that unit tests cannot capture.

2

What is the recommended library by NestJS for E2E testing?

답변

Supertest is the recommended library for E2E testing in NestJS because it allows testing HTTP endpoints without starting the server on a network port. It creates an isolated application instance and sends simulated HTTP requests directly. This makes tests faster, more reliable, and avoids port conflicts between parallel tests.

3

How to get the HTTP server instance for Supertest in a NestJS test?

답변

The app.getHttpServer() method returns the underlying HTTP server instance (Express or Fastify) that can be passed to Supertest to make test requests. This method is available after creating the test module with Test.createTestingModule(). It allows Supertest to directly access the server without having to start it on a network port.

4

In which file are E2E tests typically placed in a NestJS project?

5

Which Supertest method allows checking the status code of an HTTP response?

+17 면접 질문

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

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

무료로 시작하기