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

fix: spy on an instance and not a prototype #17

Merged
merged 2 commits into from
Jan 27, 2022

Conversation

Demivan
Copy link
Contributor

@Demivan Demivan commented Jan 27, 2022

tinyspy mocks object prototype instead of instance.
This works with nanospy

Related vitest issue: vitest-dev/vitest#645

@Demivan
Copy link
Contributor Author

Demivan commented Jan 27, 2022

@sheremet-va @Aslemammad
Locally I have removed all logic related to protoDescriptor and all tests pass now.
In which case overriding prototype was needed?

@sheremet-va
Copy link
Member

@sheremet-va @Aslemammad
Locally I have removed all logic related to protoDescriptor and all tests pass now.
In which case overriding prototype was needed?

Prototype is used only as the last resort, no?

@Demivan
Copy link
Contributor Author

Demivan commented Jan 27, 2022

First getOwnPropertyDescriptor is called on an object - it is undefined because method is on prototype.
But this does not mean that prototype override it needed. defineProperty can be called on an instance too.

@Demivan
Copy link
Contributor Author

Demivan commented Jan 27, 2022

@sheremet-va I have pushed a fix. I cannot think of fail test for this case.

All vitest tests still pass with this change.

@Demivan Demivan changed the title test: add failing test fix: spy on an instance and not a prototype Jan 27, 2022
@sheremet-va sheremet-va merged commit 5039123 into tinylibs:main Jan 27, 2022
@sheremet-va
Copy link
Member

sheremet-va commented Jan 27, 2022

Released in 0.2.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants