Cannot make stub for method `find` in Firefox 25
Brought to you by:
dewindj
Firefox 25 throws error when trying to make stub for method find
as in example
mock.expects().find().andStub(function() { return "returnValue" });
Error message is: "TypeError: this.__lastMock.calls[this.__lastCallName].push is not a function".
this.__lastMock.calls
is an array, which already has in Firefox method with name find
(and a lot of other functions), and because of this JSMock does not initialize property find
with an empty array before calling push
on it.
In fact, JSMock will throw error when creating stub for any method which name is in Array.prototype
, e.g.
In order to fix most of the problems property calls
should be declared as object, not an array:
var mock = { calls: {}, expects: function() {this.__recording = true; return this}, __recording: false};
__initializeReturnExpectationForMock()
should be also improved.