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'); }); }); });