Hi everyone, I'm a newbie to sinonjs and I need help. I want to know, how can I mock the constructor function of an class? For example, if I have this code:
var MyObject = function() {
// constructor
};
MyObject.prototype.aMethod = function() { ... };
How can I mock this object to replace the constructor with my own function? So, when I will create a new object by doing var aObject = new MyObject(); it will not call the real constructor but only the function I provided.
I've tried this without success:
var mock = sinon.mock(MyObject.prototype);
mock.expects('constructor').returns({ Dispose: function() {} });
And also:
var mock = sinon.mock(MyObject.prototype);
mock.expects('constructor').returns({ Dispose: function() {} });
So, how can I do that? Is it possible? What is the correct way to do something like this?
Thanks for your help!