Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the alternative for "toNotEqual" in Jasmine?

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?

like image 925
user122345656 Avatar asked Jun 14 '17 10:06

user122345656


1 Answers

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)

toEqual matches deep equality. It does a recursive search through the objects to determine whether the values for their keys are equivalent.

toBe matches primitive types.

like image 172
eigenharsha Avatar answered Sep 24 '22 06:09

eigenharsha