Skip to content

Support reference comparison #210

@jakubzitny

Description

@jakubzitny

Right now, the .to.equal assertion after having chai-immutable in chai does "deep" comparison. It compares the keys and values of Maps, values of Lists and so on. This breaks the original behaviour of .to.equal in chai.

I understand that it is done on purpose, and test code often needs this more than reference comparison. However, when having chai-immutable in our specs, we can't compare references, only via expect(a === b).to.be.true which is not a good practice in "having readable assertions". There is even an eslint plugin for it.

It would be cool to:

  • either change the chai-immutable's equal to eql or deep.equal and keep equal for comparing references (this will break backward compatibility here, but will unify the behaviour with the rest of chai)
  • or add a new method for comparing references, e.g. .to.referenceEqual

Would you be open to a PR for any of these? Or is there any other problem or issue regarding this?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions