Node.js / NestJS

End-to-End Testing

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

20 mülakat soruları·
Mid-Level
1

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

Cevap

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?

Cevap

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?

Cevap

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 mülakat soruları

Bir sonraki mülakatın için Node.js / NestJS'de uzmanlaş

Tüm sorulara, flashcards'a, teknik testlere, code review alıştırmalarına ve mülakat simülatörlerine eriş.

Ücretsiz başla