You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like a more informative error message for this situation:
const x = {
getFoo: () => {
return "bar"
}
}
sinon.stub(x, 'getFoo').value("baz");
console.log(x.getFoo()); // TypeError: x.getFoo is not a function
console.log(typeof x.getFoo); // string
The intent here was to stub x's getFoo method, but the user mistakenly used value to do so. In this situation, it would be more helpful for sinon to error on the stub line with an error message similar to: "x.getFoo is a function, not a getter. Use returns instead of value."
I'm aware this is a breaking change, so I think the user would need to configure some sort of "strict mode" to enable an error message like this.
The text was updated successfully, but these errors were encountered:
DanKaplanSES
changed the title
Error when stubbing a property/function that does not exist
Error when stubbing a property that does not exist
Nov 27, 2024
I'd like a more informative error message for this situation:
The intent here was to stub
x
'sgetFoo
method, but the user mistakenly usedvalue
to do so. In this situation, it would be more helpful for sinon to error on thestub
line with an error message similar to: "x.getFoo
is a function, not a getter. Usereturns
instead ofvalue
."I'm aware this is a breaking change, so I think the user would need to configure some sort of "strict mode" to enable an error message like this.
The text was updated successfully, but these errors were encountered: