Giter VIP home page Giter VIP logo

Comments (5)

mesaugat avatar mesaugat commented on July 27, 2024

@rahulworks-git Hello, can you provide an example? Do you mean you also want to assert the order of the array? If yes, this package doesn't do it.

from chai-exclude.

rahulworks-git avatar rahulworks-git commented on July 27, 2024

@mesaugat Sure.

json_1 = {
"data":
[
{
"_id": "181",
"date_time": "2008-03-11T22:24:00.000Z",
"document_id": "111",
"exp_id": "f7w7d6hs",
"note_length": "5027"
},
{
"_id": "182",
"date_time": "2001-12-18T15:53:00.000Z",
"document_id": "123",
"encounter_id": "ha7sd7hahsd6",
"note_length": "10400"
},
{
"_id": "183",
"date_time": "2001-11-20T01:43:00.000Z",
"document_id": "134",
"exp_id": "jjasd8721",
"note_length": "6281"
},
{
"note_id": "184",
"date_time": "2009-10-03T21:46:00.000Z",
"document_id": "167",
"exp_id": "sadasd871hj2",
"note_length": "5792"
}
]
}

json_2 = {
"data":
[
{
"_id": "183",
"date_time": "2001-11-20T01:43:00.000Z",
"document_id": "134",
"exp_id": "jjasd8721",
"note_length": "6281"
},
{
"_id": "181",
"date_time": "2008-03-11T22:24:00.000Z",
"document_id": "111",
"exp_id": "f7w7d6hs",
"note_length": "5027"
}
,
{
"note_id": "184",
"date_time": "2009-10-03T21:46:00.000Z",
"document_id": "167",
"exp_id": "sadasd871hj2",
"note_length": "5792"
},
{
"_id": "182",
"date_time": "2001-12-18T15:53:00.000Z",
"document_id": "123",
"encounter_id": "ha7sd7hahsd6",
"note_length": "10400"
}
]
}

When i am using deepEqualExcludingEvery, then i get the response that the above 2 json are not the same whereas i am expecting them be the same. For my use case, the order of the records in an array does not matter, only the elements inside the array should not be different.

from chai-exclude.

mesaugat avatar mesaugat commented on July 27, 2024

@rahulworks-git Got it. Deep equality in chai by default seems to also care about the order of the objects. (Didn't know about this 😅)

Maybe you can use this plugin: https://github.com/oprogramador/deep-equal-in-any-order

expect(json_1).excludingEvery('a').to.deep.equalInAnyOrder(json_2)

from chai-exclude.

rahulworks-git avatar rahulworks-git commented on July 27, 2024

@mesaugat This seemed to have worked partially. I need some help from you. Is it possible to connect over any meeting platform? Maybe i can share screen for a while and discuss the use case.

from chai-exclude.

mesaugat avatar mesaugat commented on July 27, 2024

@rahulworks-git Hey sorry Rahul, I'm generally busy with my work. You can create an issue in the repository and I can take a look at it when I find the time.

Closing this issue for now.

from chai-exclude.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.