Performance: Integration testing
Integration testing affects development and CI pipeline speed, impacting how quickly changes can be verified and deployed.
beforeAll(async () => { const moduleRef = await Test.createTestingModule({ imports: [SpecificModule], }).compile(); app = moduleRef.createNestApplication(); await app.init(); });
beforeEach(async () => { const moduleRef = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleRef.createNestApplication(); await app.init(); });
| Pattern | Test Initialization Time | Resource Usage | Parallelizability | Verdict |
|---|---|---|---|---|
| Full AppModule per test | High (500ms+) | High (DB, services) | Low | [X] Bad |
| Specific Module once per suite | Low (100ms) | Low | High | [OK] Good |
const response = await request(app.getHttpServer()).get('/users');
expect(response.status).toBe(200);let app;
beforeAll(async () => {
app = Test.createTestingModule({ imports: [AppModule] });
await app.init();
});Pass the test and this pattern moves unknown