Ad

Chai Deep Equal And Equal Not Working

- 1 answer

Some how chai its not working

promise = doSomething()

expect(promise).to.eventually.equal(obj)

expect(promise).to.eventually.deep.equal(obj)

but in the assertion error I get this

AssertionError: expected {a: "2", b: "3"} to equal {a: "2", b: "3"}

BTW I already try with should and I get the same result

Ad

Answer

I guess maybe the value return from promise is string of JSON, like

"{a: '2', b: '3'}"

Which case I met before. If so, try JSON.parse() this value before deep equal operation.

Ad
source: stackoverflow.com
Ad