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

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

Closed
flotwig opened this issue Feb 3, 2020 · 1 comment · Fixed by #2216
Closed

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

flotwig opened this issue Feb 3, 2020 · 1 comment · Fixed by #2216

Comments

@flotwig
Copy link
Contributor

flotwig commented Feb 3, 2020

Describe the bug

Trying to run toString on certain spies results in an error.

In Chromium-based browsers:

TypeError: Illegal invocation
    at Function.toString (sinon.js:3417)
    at JjogzZG?editors=1000:26

In Firefox:

TypeError: "'get onclick' called on an object that does not implement interface Notification."
    sinon 8.1.1/pkg/sinon.js:3417
    <anonymous> https://cdpn.io/boomboom/v2/index.html?editors=1000&key=iFrameKey-ce3ac7bf-f321-9ff3-df5c-2db10a31e480:22

To Reproduce

On line 3, the error will be thrown:

const spy = sinon.spy(window, 'Notification')
new Notification('hello')
console.log(spy.toString())

CodePen (check console for output): https://codepen.io/flotwig/pen/JjogzZG?editors=1000

Expected behavior

toString works without erroring.

Context (please complete the following information):

@flotwig
Copy link
Contributor Author

flotwig commented Feb 3, 2020

Opened a PR with a fix that should be suitable: #2216

mroderick pushed a commit that referenced this issue Feb 19, 2020
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 a pull request may close this issue.

1 participant