I am trying to write Unit Test in Jasmine and in my code, I am comparing two objects for inequality.
I am using following code to do it:
expect(obj1).toNotEqual(obj2)
But getting following error:
TypeError: expect(...).toNotEqual is not a function
Can anyone please suggest how to resolve this?
It could have been more useful if you specified the Jasmine Version you are using.
But anyway answer to your question is .. all Jasmine versions 1.3,2.0,2.1 to 2.5 don't support toNotEqual and in case you want to check inequality you have to chain NOT to expect before the matches.
Use not.toEqual for check inequality of object.
expect(obj1).not.toEqual(obj2)
toEqualmatches deep equality. It does a recursive search through the objects to determine whether the values for their keys are equivalent.
toBematches primitive types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With