Match partial objects in Chai assertions?

前端 未结 8 2071
谎友^
谎友^ 2021-01-07 18:07

I am looking for the best way to match the following:

expect([
    {
        C1: \'xxx\',
        C0: \'this causes it not to match.\'
    }
]).to.deep.incl         


        
8条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 18:25

    I believe the simplest (and certainly easiest) way would be to:

    var actual=[
      {
        C1:'xxx',
        C0:'yyy'
      }
    ];
    
    actual.forEach(function(obj){
      expect(obj).to.have.property('C1','xxx');
    });
    

提交回复
热议问题