Match partial objects in Chai assertions?

前端 未结 8 2069
谎友^
谎友^ 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:41

    Slightly updated version of #RobRaisch because for empty comparison giving error because '' not equal ""

    let expected = {
                dateOfBirth: '',
                admissionDate: '',
                dischargeDate: '',
                incidentLocation: null
            };
            Object.keys(expected).forEach(function(key) {
                expect(actual[key]).to.equal(expected[key]);
            });
    

提交回复
热议问题