Files
lms-be/test/app.e2e-spec.ts
T
2026-07-07 16:09:12 +09:00

40 lines
1006 B
TypeScript

import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { AppModule } from '../src/app.module';
import { PrismaService } from '../src/prisma/prisma.service';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
})
.overrideProvider(PrismaService)
.useValue({
$connect: jest.fn(),
$disconnect: jest.fn(),
$queryRaw: jest.fn().mockResolvedValue([{ '?column?': 1 }]),
})
.compile();
app = moduleFixture.createNestApplication();
await app.init();
});
afterEach(async () => {
await app.close();
});
it('/health (GET)', () => {
return request(app.getHttpServer())
.get('/health')
.expect(200)
.expect(({ body }) => {
expect(body.status).toBe('ok');
});
});
});