sinonjs / sinon

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

Spies for property accessors are not automatically cleaned up #2534

Closed fatso83 closed 11 months ago

fatso83 commented 11 months ago

Describe the bug If we use Sinon to spy on property accessors, these spies are not cleaned up (restored) when restoring the sandbox.

To Reproduce Steps to reproduce the behavior:

const executeInsertSpy = sinon.spy(o, "executeInsert", ["get"]);
o.executeInsert
o.executeInsert
assert.equals(executeInsertSpy, 2);
sinon.restore();
executeInsertSpy.get.restore(); // We should not be able to or be required to do this. BUG!

Expected behavior All spies are cleaned up

Context (please complete the following information):

Library version: 15.2.0 Environment: node v18.16.1

Additional context Found when deep diving into #2523

Runnable example https://runkit.com/fatso83/649df02251b50f0008d1e3a6