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

[Bug]: structuredClone is not defined #12628

Closed
Araxeus opened this issue Apr 3, 2022 · 4 comments · Fixed by #12631
Closed

[Bug]: structuredClone is not defined #12628

Araxeus opened this issue Apr 3, 2022 · 4 comments · Fixed by #12631

Comments

@Araxeus
Copy link
Contributor

Araxeus commented Apr 3, 2022

Version

27.5.1 / v28.0.0-alpha.7

Steps to reproduce

try to use the global structuredClone inside a test
(https://nodejs.org/api/globals.html#structuredclonevalue-options)
(https://developer.mozilla.org/en-US/docs/Web/API/structuredClone)

Expected behavior

it is defined and works

Actual behavior

global.structuredClone is not defined

Additional context

Running the same code outside of jest works fine, but somehow jest seems to delete that global?

image

str.js:

console.log({
    nodeVersion: process.versions.node,
    structuredClone: global.structuredClone
});

str.test.js:

console.log({
    nodeVersion: process.versions.node,
    structuredClone: global.structuredClone
});
expect(global.structuredClone).toBeDefined();

Environment

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz
  Binaries:
    Node: 17.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.6.0 - C:\Program Files\nodejs\npm.CMD
@SimenB
Copy link
Member

SimenB commented Apr 4, 2022

PR welcome, change should be around here: https://github.com/facebook/jest/blob/80cf80055682919251b9567ef482755d5f060d47/packages/jest-environment-node/src/index.ts#L89-L92

@Araxeus
Copy link
Contributor Author

Araxeus commented Apr 4, 2022

Thanks for the hint, I opened a PR

@SimenB
Copy link
Member

SimenB commented Apr 5, 2022

https://github.com/facebook/jest/releases/tag/v28.0.0-alpha.8

@github-actions
Copy link

github-actions bot commented May 6, 2022

This issue 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 May 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants