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.toString when getters on a spy's thisValue throw #2216

Merged
merged 2 commits into from Feb 19, 2020

Conversation

flotwig
Copy link
Contributor

@flotwig flotwig commented Feb 3, 2020

Purpose (TL;DR)

Fix #2215 by ignoring errors thrown from property getters - since the algo is just looking for thisValue[prop] === this, errors are irrelevant.

Background (Problem in detail)

This was uncovered when trying to spy on the Notification constructor in #2215, but this could happen with any object. The tests for this PR include such an example.

Solution

Ignore the error. There is nothing to do.

How to verify

  1. Check out this branch
  2. npm install
  3. run the test without the changes, then run the test with the changes

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@mroderick
Copy link
Member

Thank you for taking the time to give both an in-depth error report and a great pull request 💯

@mroderick mroderick merged commit a49167c into sinonjs:master Feb 19, 2020
@mroderick
Copy link
Member

This has been published as part of sinon@9.0.0

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.

"Illegal invocation" when using toString() on a cy.spy for a native object
2 participants