NestJS 11 · Testing
Unit test a service
Build a small testing module with only what the test needs.
const moduleRef = await Test.createTestingModule({
providers: [CatsService],
}).compile();
const service = moduleRef.get(CatsService);
expect(service.findAll()).toEqual([]);
Official NestJS 11 documentation