0
0
NestJSframework~5 mins

E2E testing with supertest in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of E2E testing in a NestJS application?
E2E testing checks the whole application flow from start to finish, ensuring all parts work together as expected, like a user interacting with the app.
Click to reveal answer
beginner
What role does Supertest play in E2E testing with NestJS?
Supertest helps simulate HTTP requests to the NestJS app, allowing tests to check responses without needing a real browser or client.
Click to reveal answer
intermediate
How do you start a NestJS application instance for E2E testing with Supertest?
You create a testing module with Test.createTestingModule, compile it, then create a Nest application instance and call app.init() before running tests.
Click to reveal answer
intermediate
Why is it important to close the NestJS app after E2E tests finish?
Closing the app frees resources and stops the server, preventing conflicts or memory leaks when running multiple tests.
Click to reveal answer
intermediate
What is a common pattern to test an HTTP POST request using Supertest in NestJS E2E tests?
Use supertest's request(app.getHttpServer()).post('/route').send(data).expect(statusCode) to send data and check the response status and body.
Click to reveal answer
Which method initializes the NestJS app instance for E2E testing?
Aapp.init()
Bapp.start()
Capp.run()
Dapp.launch()
What does Supertest simulate in E2E tests?
ADatabase queries
BFile uploads
CHTTP requests
DUser interface clicks
In NestJS E2E tests, where do you get the HTTP server instance for Supertest?
Aapp.getHttpServer()
Bapp.getServer()
Capp.getRequestHandler()
Dapp.getListener()
Why should you call app.close() after E2E tests?
ATo reset the database
BTo stop the server and free resources
CTo clear test data
DTo restart the app automatically
Which NestJS testing utility helps create a testing module for E2E tests?
ANestFactory.createTesting()
BTestingModule.create()
CTestModule.build()
DTest.createTestingModule()
Explain the steps to set up and run an E2E test in NestJS using Supertest.
Think about setup, request simulation, assertions, and cleanup.
You got /6 concepts.
    Describe why E2E testing with Supertest is useful for a NestJS application.
    Focus on the benefits of testing the whole app behavior.
    You got /4 concepts.