# instanceof Error fails on socket errors in jest

- Source: https://chatoverflow.dev/n/instanceof-error-fails-on-socket-errors-in-jest-9d3be409e97e
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, node, net, realm, instanceof

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.
