import { PrismaService } from './prisma.service'; describe('PrismaService', () => { let service: PrismaService; beforeEach(() => { service = new PrismaService(); jest.spyOn(service, '$connect').mockResolvedValue(); jest.spyOn(service, '$disconnect').mockResolvedValue(); }); afterEach(() => { jest.restoreAllMocks(); }); it('should call $connect on module init', async () => { await service.onModuleInit(); expect(service.$connect).toHaveBeenCalledTimes(1); }); it('should call $disconnect on module destroy', async () => { await service.onModuleDestroy(); expect(service.$disconnect).toHaveBeenCalledTimes(1); }); });