34 lines
833 B
TypeScript
34 lines
833 B
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication, ValidationPipe } from '@nestjs/common';
|
|
import { AppModule } from '../src/app.module';
|
|
|
|
let app: INestApplication;
|
|
let moduleFixture: TestingModule;
|
|
|
|
beforeAll(async () => {
|
|
try {
|
|
moduleFixture = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
app.useGlobalPipes(new ValidationPipe({ transform: true }));
|
|
await app.init();
|
|
|
|
global.testApp = app;
|
|
console.log('E2E test application initialized');
|
|
} catch (error) {
|
|
console.warn('Could not initialize E2E test app:', error.message);
|
|
}
|
|
});
|
|
|
|
afterAll(async () => {
|
|
if (app) {
|
|
await app.close();
|
|
}
|
|
});
|
|
|
|
declare global {
|
|
var testApp: INestApplication;
|
|
}
|