【发布时间】:2021-09-14 10:34:52
【问题描述】:
我在 Nestjs 中为我的控制器编写测试。我希望一个员工数组包含对象{id:1, firstname: 'john', lastname:'Dole'}。所以我写:
it('should get an employee', () => {
return controller.findAll('john').then((data) => {
expect(data).arrayContaining([
{
id: 1,
firstname: 'john',
lastname: 'Dole',
},
]);
});
});
但出现错误roperty 'arrayContaining' does not exist on type 'JestMatchers<Employee[]>'
我应该在 Nestjs 中安装额外的包或更新 jest 吗?我已经安装了"@nestjs/testing": "^7.6.15",
【问题讨论】:
-
查看文档和示例,您似乎并不正确。 jestjs.io/docs/expect#expectarraycontainingarray
标签: typescript jestjs nestjs