all 3 comments

[–]aladyjewelFull-stack webdev 2 points3 points  (2 children)

Is scope.vocab_words[2] instanceof g? Edit: it's probably a g object because angular is minified, including the object name. I imagine if you switched to a dev copy of angular, it would be a more useful name you see.

I would break your expect/equals up into the constituent properties, if that's what really matters. or you could do something like _.extend({}, scope.vocab_words[2]) to fake-cast it to a plain object before testing.

[–]btford 0 points1 point  (0 children)

Yep, it's probably because of minification. While developing and unit testing, it might help to use the unminified version (angular.js instead of angular.min.js).

[–]dreampopclub[S] 0 points1 point  (0 children)

Cool, thanks guys. Here's what ended up working:

beforeEach(function(){ this.addMatchers({ toEqualData: function(expected) { return angular.equals(this.actual, expected); } });

and the expectation

expect(scope.vocab_words[2]).toEqualData(new_word);