I am new in typescript and nestjs and I am trying to learn nest js, But when I am trying to Unit test my code then result variable gives me an error shown in the title? Anyone helps me to try to find what I am doing wrong here.
describe('cats', () => {
let controller: CatsController;
let service: CatsService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [DeliveryController],
}).compile();
controller = module.get<CatsController>(CatsController);
});
describe('', () => {
it('should return an array of cats', async () => {
const result = [
{
id: "1",
name: "Cat",
type: "hybrid"
}
];
jest.spyOn(service, 'getCats').mockImplementation(() => result); //'result' in this line shows error
expect(await controller.getAllCats()).toBe(result);
});
})
});