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

[Feature]: Upgrade jest-environment-jsdom from v22 to v24 to avoid deprecated punycode warning #15148

Closed
jschaf opened this issue Jun 25, 2024 · 6 comments

Comments

@jschaf
Copy link

jschaf commented Jun 25, 2024

🚀 Feature Proposal

Upgrade jsdom to v24 from v22.

The current chain of dependencies from jest-environment-jsdom import punycode. As of Node 21, requiring punycode emits a deprecation warning.

The dependency chain is:

  • jest-environment-jsdom
  • depends on jsdom ^22.0.0
  • depends on tough-cookie ^4.1.2
  • tough-cookie 4.1.2 depends on psl ^1.9.0
  • psl depends on node:punycode

tough-cookie replaced psl with tldts in salesforce/tough-cookie#346, avoiding the deprecation warning.

Motivation

Every test with jsdom logs a deprecation warning:

(node:15100) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:398:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:337:10)
    at loadBuiltinModule (node:internal/modules/helpers:104:7)
    at Function.Module._load (node:internal/modules/cjs/loader:999:17)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/opt/p/simc/node_modules/psl/index.js:5:16)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1426:10)

Example

Should be no change excepting breaking changes in jsdom.

Pitch

Because jest already imports jsdom.

@opyate
Copy link

opyate commented Jun 27, 2024

Here's one more DeprecationWarning stack, in case it sheds more light.

  • jest-environment-jsdom: ^29.7.0
  • jsdom: 20.0.3
  • tought-cookie: 4.1.4
  • psl: 1.9.0
> NODE_OPTIONS='--trace-deprecation' jest src/server/views/__tests__/login.njk.test.ts

(node:479351) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
    at node:punycode:3:9
    at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:397:7)
    at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:333:10)
    at loadBuiltinModule (node:internal/modules/helpers:101:7)
    at Function.Module._load (node:internal/modules/cjs/loader:1006:17)
    at Module.require (node:internal/modules/cjs/loader:1237:19)
    at require (node:internal/modules/helpers:176:18)
    at Runtime._requireCoreModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1543:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:840:19)
    at Runtime.requireModuleOrMock (/path-to-my-app/node_modules/jest-runtime/build/index.js:1048:21)
    at Object.<anonymous> (/path-to-my-app/node_modules/psl/index.js:5:16)
    at Runtime._execModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:882:12)
    at Runtime.requireModuleOrMock (/path-to-my-app/node_modules/jest-runtime/build/index.js:1048:21)
    at Object.<anonymous> (/path-to-my-app/node_modules/tough-cookie/lib/pubsuffix-psl.js:32:13)
    at Runtime._execModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:882:12)
    at Runtime.requireModuleOrMock (/path-to-my-app/node_modules/jest-runtime/build/index.js:1048:21)
    at Object.<anonymous> (/path-to-my-app/node_modules/tough-cookie/lib/cookie.js:34:19)
    at Runtime._execModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:882:12)
    at Runtime.requireModuleOrMock (/path-to-my-app/node_modules/jest-runtime/build/index.js:1048:21)
    at Object.<anonymous> (/path-to-my-app/node_modules/jsdom/lib/api.js:5:21)
    at Runtime._execModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:882:12)
    at Runtime.requireModuleOrMock (/path-to-my-app/node_modules/jest-runtime/build/index.js:1048:21)
    at Object.<anonymous> (/path-to-my-app/src/server/views/__tests__/login.njk.test.ts:18:17)
    at Runtime._execModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1439:24)
    at Runtime._loadModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:1022:12)
    at Runtime.requireModule (/path-to-my-app/node_modules/jest-runtime/build/index.js:882:12)
    at jestAdapter (/path-to-my-app/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:77:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runTestInternal (/path-to-my-app/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/path-to-my-app/node_modules/jest-runner/build/runTest.js:444:34)

@SimenB
Copy link
Member

SimenB commented Jul 1, 2024

Duplicate of #15089 (comment) et.al.

@SimenB SimenB closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
@jschaf
Copy link
Author

jschaf commented Jul 1, 2024

Based on #14846, do you mean this is a won't fix until Jest drops support for Node 16?

jsdom has dropped node 16, which I intend to support in the next release. However, creating a custom env with whatever version of jsdom you like should be easier in jest 30 via #14717.

Node 16 reached end-of-life in September 2023.

For tracking puposes, I'd prefer to keep this open unless it's a wontfix since the linked PRs (#15089, #14846 (comment), #14954 (comment)) are all closed.

@SimenB
Copy link
Member

SimenB commented Jul 1, 2024

Correct, however I'll probably publish a package for v24 for those that don't need node 16

@aaronzshey
Copy link

Another reason that we should use jsdom 24 instead of 22 - jsdom 22 depends on abab and domexception, both of which are also deprecated!

Copy link

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 Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants