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 "instanceof Error" #8220

Closed
wants to merge 1 commit into from
Closed

Fix "instanceof Error" #8220

wants to merge 1 commit into from

Conversation

gkubisa
Copy link

@gkubisa gkubisa commented Mar 26, 2019

Partially fixes #2549.

It fixes only instanceof Error and does not affect instanceof AnySubClassOfError nor any other instanceof usage. Because it is so specific, I don't think it is suitable for merging. #5995 would certainly be a better fix, if it worked.

Comparing my fix and #5995, I think the problem might be that errors are somehow mishandled in jest itself, which results in issues with instanceof SubClassOfError checks within jest. Once those are fixed, #5995 should just work. Does it make sense?

cc @SimenB

@feugy
Copy link

feugy commented Apr 2, 2019

You saved my life @gkubisa. Until this PR is merged, our tests will still work

Comment on lines +6 to +8
return this === error
? toString.call(potentialInstance) === '[object Error]'
: originalHasInstance.call(this, potentialInstance);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: because jest supports node >= 10 now, I think that util.types.isNativeError would work. I did only some limited test and it worked for my small case.

@github-actions
Copy link

github-actions bot commented Sep 8, 2022

This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 8, 2022
@github-actions
Copy link

github-actions bot commented Oct 8, 2022

This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this Oct 8, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest globals differ from Node globals
4 participants