forked from mtusi2026/mtusi2026lab2
feat: explain analyze
This commit is contained in:
+14
-7
@@ -17,16 +17,23 @@ export interface TestUser {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export async function createTestApp(): Promise<{
|
||||
export async function createTestApp(env: Record<string, string> = {}): Promise<{
|
||||
app: INestApplication;
|
||||
server: any;
|
||||
}> {
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
const app = moduleRef.createNestApplication<NestFastifyApplication>(
|
||||
new FastifyAdapter(),
|
||||
);
|
||||
const saved = { ...process.env };
|
||||
Object.assign(process.env, env);
|
||||
let app: NestFastifyApplication;
|
||||
try {
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
app = moduleRef.createNestApplication<NestFastifyApplication>(
|
||||
new FastifyAdapter(),
|
||||
);
|
||||
} finally {
|
||||
process.env = saved;
|
||||
}
|
||||
configureApp(app);
|
||||
await app.listen(0, '127.0.0.1');
|
||||
return { app, server: app.getHttpServer() };
|
||||
|
||||
Reference in New Issue
Block a user