0

toEqual() is what one would use to compare two objects in jasmine tests, right? i am puzzled as to why i am getting the following error in my test:

Expected StoreExcludes({ id: 1, location: 'TK-LV', storeNumber: 10, name: 'RIGA', ranking-level-1: true, ranking-level-2: true, all: true }) to equal Object({ id: 1, location: 'TK-LV', storeNumber: 10, name: 'RIGA', ranking-level-1: true, ranking-level-2: true, all: true }).

any ideas?

Иван Грозный
  • 9,331
  • 12
  • 49
  • 84
  • Objects comparing isn't that simple in JS (in plain js `{foo:2}=={foo:2}` will return false). If no method was given by Jasmine, one way could be to use `JSON.stringify` on each object before comparing – angrykoala Apr 14 '16 at 08:11
  • @see http://stackoverflow.com/questions/22413009/jasmine-javascript-testing-tobe-vs-toequal. Furthermore, the objects you are comparing have different types. The first one is of type StoreExcludes, the latter of plain type object. Hence, they have a different prototype and the comparison will fail. – Dennis Jaamann Apr 14 '16 at 08:31

0 Answers0