Jasmine toEqual for complex objects (mixed with functions)
问题 Currently, I have a function that sometimes return an object with some functions inside. When using expect(...).toEqual({...}) it doesn't seem to match those complex objects. Objects having functions or the File class (from input type file), it just can't. How to overcome this? 回答1: Try the Underscore _.isEqual() function: expect(_.isEqual(obj1, obj2)).toEqual(true); If that works, you could create a custom matcher: this.addMatchers({ toDeepEqual: function(expected) { return _.isEqual(this