3

I'm using Karma with Jasmine for my javascript unit tests. Suppose I have a failing test like this:

 expect(objectA).toEqual(expectedObjectA);

When it fails, I see the two objects dumped on the console and a message telling me the objects are not equal:

console test result

This is not very helpful because in order to find out why they are not equal, I have to to copy paste the text from the console, split the two objects from that object dump, format them, put them in a diff editor. (Sometimes even that doesn't help because the object are not equal because they have members which are functions).

Is there a way to make jasmine dump to the console the exact name and value of the first property that differs between the two objects?

Is there a way to see the object dump pretty printed? (not really necessary, but it would be nicer than this unreadable dump)

Liviu Trifoi
  • 2,980
  • 1
  • 21
  • 28
  • 1
    I think this is a duplicate of : [Karma jasmine tests: Highlight diff in terminal](http://stackoverflow.com/questions/23429709/karma-jasmine-tests-highlight-diff-in-terminal). An [issue](https://github.com/karma-runner/karma/issues/627) has been raised but remains unpursued. – glepretre Jun 11 '14 at 08:45

1 Answers1

-2

Looks like you may need a custom matcher.
Have you had a look at this question ? Jasmine toEqual for complex objects (mixed with functions)

Community
  • 1
  • 1
blorkfish
  • 21,800
  • 4
  • 33
  • 24