Skip to content

[Bug]: "instanceof Error" fails under Jest #11808

@cakoose

Description

@cakoose

Version

27.1.0

Steps to reproduce

Clone https://github.com/cakoose/jest-instanceof-bug

yarn install
yarn run tsc --build

node dist/normal.js
# the console shows `instanceof` checks yielding `true`.

jest dist/test.js
# the console shows `instanceof` tests yielding `false`.

Expected behavior

When running under jest, I expect the instanceof checks to yield true, just like they do when I run under node.

Actual behavior

The instanceof checks yield false.

Additional context

No response

Environment

$ npx envinfo --preset jest
Need to install the following packages:
  envinfo
Ok to proceed? (y) y

  System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 16.4.1 - ~/.volta/tools/image/node/16.4.1/bin/node
    Yarn: 1.22.10 - ~/.volta/tools/image/yarn/1.22.10/bin/yarn
    npm: 7.18.1 - ~/.volta/tools/image/node/16.4.1/bin/npm

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions