Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spies for property accessors are not automatically cleaned up #2534

Closed
fatso83 opened this issue Aug 9, 2023 · 0 comments
Closed

Spies for property accessors are not automatically cleaned up #2534

fatso83 opened this issue Aug 9, 2023 · 0 comments
Labels
Bug Property accessors Property Getters/Setters

Comments

@fatso83
Copy link
Contributor

fatso83 commented Aug 9, 2023

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

@fatso83 fatso83 added Bug Property accessors Property Getters/Setters labels Aug 9, 2023
fatso83 added a commit that referenced this issue Aug 11, 2023
fatso83 added a commit that referenced this issue Aug 11, 2023
* Document the custom property descriptor type used in Sinon

* Fix issue #2534

* prettify
@fatso83 fatso83 closed this as completed Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Property accessors Property Getters/Setters
Projects
None yet
Development

No branches or pull requests

1 participant