The example below is simplified. I have a getter method:
class MyClass {
constructor() {}
get myMethod() {
return true;
}
}
which is processed by babel. And I want to mock this as follows:
var sinon = require('sinon');
var MyClass = require('./MyClass');
var cls = new MyClass();
var stub = sinon.stub(cls, 'myMethod');
stub.returns(function() {
return false;
});
But I get the following error:
TypeError: Attempted to wrap undefined property myMethod as function
And this happens on both versions 1 and 2 of the sinon library.
source
share