我是nestjs和jest的新手,我想对nestjs中的代码进行单元测试,但是result
变量显示错误[]' is not assignable to type 'Cat[]'.
,我试图解决很多问题,但未能得到这个。请帮助我解决这个问题,并找出我在这里做错了什么?
describe('', () => {
it('should return an array of cats', async () => {
const result = [
{
id: "1",
name: "Cat",
type: "hybrid"
}
];
jest.spyOn(service, 'getCats').mockImplementation(():Promise<Cat[]> => new Promise((resolve, reject) => resolve(result)));// result shows error
expect(await controller.getAllCats()).toBe(result);
});
})