-
-
Notifications
You must be signed in to change notification settings - Fork 774
Open
Description
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.
fatso83
Metadata
Metadata
Assignees
Labels
No labels