sinonjs / sinon

Test spies, stubs and mocks for JavaScript.
https://sinonjs.org/
Other
9.61k stars 769 forks source link

Improve error message for immutable descriptors to include link to article #2533

Open fatso83 opened 11 months ago

fatso83 commented 11 months ago

Is your feature request related to a problem? Please describe. See https://github.com/sinonjs/sinon/issues/2528#issuecomment-1670898956. Currently it seems people get stuck when seeing the error message "Descriptor for property toBeMocked is non-configurable and non-writable" and think this is some sort of error in Sinon.

Describe the solution you'd like I was thinking that it might be useful to have error messages point directly to relevant docs that could give the user some context and possible hints at resolving the issue. So instead of "Descriptor for property toBeMocked is non-configurable and non-writable" change it to something like

The descriptor for the property toBeMocked is non-configurable and non-writable. Sinon cannot do anything about this, as it is essentially immutable. Read https://sinonjs.org/faqs#immutable-objectdescriptor for tips on what could cause this and how to possibly resolve it.

(The link is made up by the way). A fix should of course then include a new page in our docs that deals with that specific error. It could contain a short summary of possible reasons the descriptor is immutable (such as transpilation of ESM) and links to articles that show how to solve it.

stale[bot] commented 7 months ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.