'arraycontaining' 在类型 'jestmatchers' 上不存在

'arraycontaining' does not exist on type 'jestmatchers'

我在 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",

arrayContaining 本身不做任何匹配,而是 returns 一个可以与例如一起使用的匹配器toEqual,像这样:

      expect(data).toEqual(expect.arrayContaining([
        {
          id: 1,
          firstname: 'john',
          lastname: 'Dole',
        },
      ]));