jest: [Bug]: Object.getOwnPropertySymbols() does not work against global instance with jest+node18

Version

27/28/29

Steps to reproduce

run the following test case:

it(‘Object.getOwnPropertySymbols does not work against global instance with jest+node18’, () => { const KEY = Symbol.for(‘key’);

expect(global[KEY]).toBe(undefined); expect(Object.getOwnPropertySymbols(global).includes(KEY)).toBe(false);

global[KEY] = ‘hello’;

expect(global[KEY]).toBe(‘hello’); expect(Object.getOwnPropertySymbols(global).includes(KEY)).toBe(true); });

Expected behavior

the test should pass

Actual behavior

the test passes with Node JS <16, fails starting with Node JS 18

Additional context

No response

Environment

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 18.10.0 - ~/.nvm/versions/node/v18.10.0/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.10.0/bin/npm
  npmPackages:
    jest: 28.1.3 => 28.1.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 33 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Fails on Node v18.16, but works as expected on Node v18.17.

@dubzzz, you fixed it! Thanks.

Let’s probably wait Node 19 release 🤔 I think it will come soon. At least I hope it will 😂

A fix should land soon in node 19. If no issue occurs, it will possibly be backported in node 18. More at https://github.com/nodejs/node/pull/46458

I just reported the very same issue on #13696. Definitely something strange going on 🤔 I tried to investigate a bit what can go wrong but so far no clue at all