Chai test array of objects to “contain something like” an object submatch

前端 未结 3 391
我在风中等你
我在风中等你 2021-01-21 05:15

Ok. I\'ve tried to read other questions here but still didn\'t find a straightforward answer.

How can I assert a partial object match in an array using chai? Something

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 05:56

    Not sure why you dismissed chai-subset as this seems to work:

    expect(data).to.be.an("array").to.containSubset([{ name: "test" }]);
    

提交回复
热议问题