sinonjs / sinon

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

Use no-op for every function when restoring instances #2499

Closed fatso83 closed 1 year ago

fatso83 commented 1 year ago

Purpose (TL;DR) - mandatory

Fixes the issue brought up in #2477 by adding default no-op implementations of all the functions present on the prototype of a stub instance object. This avoids issues that might arise if code traverses an object that already has been restored by having a default set of no-op function to fiddle with, instead of accidentally invoking stuff on the prototype which might or might not depend on the constructor being run to work correctly.

How to verify - mandatory

npm test and check against the example in #2477

Checklist for author