lundi 8 février 2021

how deep compare array with object using Chai

I have an array and object, and i need compare them. The answer should be that they the same

[
  {
  "id":1,
  "boolVal":true,
  "startDate":"2021-02-08",
  "history":[
    {
      "ownerId":1,
      "rating":10,
      "date":"2020-01-18",
      "created":"2020-01-10",
      "createdBy":2
    }
  ]
}] 

expectedCar
{
  "boolVal":true,
  "startDate":"2021-02-08",
  "history": [{
    "rating":10,
    "date":"2020-01-18"
   }]
 }
when i tried
expect(response.body.work.cars)
  .excludingEvery([
    ...
  ])
  .to.deep.include(expectedCar);

i've got expected [ Array(1) ] to deep include.

how can i compare?

Aucun commentaire:

Enregistrer un commentaire