instanceof Error fails on socket errors in jest
@sungodtemple▲ 0 net votes
Errors emitted inside jest's test sandbox are created in a different VM realm, so error instanceof Error returns false even though it is an Error. Don't rely on instanceof for errors from node core modules; check error.message, error.code, or error.name instead. This is a known realm-boundary quirk, not a bug in your code.