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 dependency to jsdom@^26.0.0 #15325

Closed
ThomasGreenspan opened this issue Sep 27, 2024 · 18 comments
Closed

Comments

@ThomasGreenspan
Copy link

ThomasGreenspan commented Sep 27, 2024

🚀 Feature Proposal

For package jest-environment-jsdom, change dependency on jsdom from:
"jsdom": "^22.0.0"
to
"jsdom": "^25.0.1"

Edit: now should be ^26.0.0

Motivation

jsdom versions before 25.0.1 (including 25.0.0) indirectly rely on punycode which is deprecated and emits deprecation warnings for every test.

A more detailed explanation can be found on this older issue which was closed without addressing (although I believe it needs to be ugpraded all the way up to v25):
#15148

Example

No response

Pitch

The package already relies on jsdom, this is just requesting an upgrade of one of its dependencies.

I currently use a dependency override and the behavior is fully preserved. Of course, I have a limited set of tests so I'm not sure that there is no impact but it is possible that this is a very small effortless change. While the override does handle my issue, overrides are always a little dangerous and I think it would be good for the lib to not rely on deprecated code.

@loucadufault
Copy link

loucadufault commented Oct 2, 2024

Further motivation: a number of APIs are missing in older jsdom versions that were recently added, e.g. crypto.randomUUID() added in [email protected]

@loucadufault
Copy link

loucadufault commented Oct 2, 2024

As a side-note, the current latest [email protected] depends on jsdom@^20.0.0 (not 22.0.0 as mentioned in the original issue post).

@davidagitlen
Copy link

As a follow-on to the above side-note, including jsdom@^20.0.0 also has the side effect of pulling deprecated code like abab and outdated versions of data-urls ...

@dmurvihill
Copy link

dmurvihill commented Oct 6, 2024

+1. it looks like the latest alpha still has jsdom 22. But v23 is the first one without the deprecated abab and domexception packages.

% npm install -D jest jest-environment-jsdom @testing-library/react @testing-library/dom @testing-library/jest-dom
npm warn deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
npm warn deprecated [email protected]: Use your platform's native DOMException instead
% npm ls abab
[email protected] /Users/dolan/IdeaProjects/todo-heap
└─┬ [email protected]
  └─┬ [email protected]
    ├── [email protected]
    └─┬ [email protected]
      └── [email protected] deduped

 % npm ls domexception
[email protected] /Users/dolan/IdeaProjects/todo-heap
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

@lintu22
Copy link

lintu22 commented Oct 16, 2024

Versions of jsdom below 24.1.2 rely on a vulnerable version of ws package. https://nvd.nist.gov/vuln/detail/CVE-2024-37890.

@jemunk
Copy link

jemunk commented Oct 30, 2024

How about giving this issue a bit more focus like changing it from a Feature Request to a Bug?

@tylerd-canva
Copy link

even renovate wants this #15276

@brinehart
Copy link

Any updates on this? We are still seeing this message on every one of our test suite runs:

(node:10249) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

It's rather annoying.

Copy link

github-actions bot commented Jan 3, 2025

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Jan 3, 2025
@davidagitlen
Copy link

I would still like this to be fixed, so... it's not stale to me

@github-actions github-actions bot removed the Stale label Jan 3, 2025
@it11ah1
Copy link

it11ah1 commented Jan 14, 2025

With jsdom@^26.0.0 "Error: Could not parse CSS stylesheet" when css @layer rule is used would also be fixed...

@andreibereczki
Copy link

+1. this would fix all the above mentioned issues and more. please upgrade this dependency

@ThomasGreenspan
Copy link
Author

Hey folks, does anyone here know how to get the attention of people in this repo? It seems like a lot of people want this? It also seems like the last change to this package was 5 months ago (the repo is still being worked on though).

@andreibereczki
Copy link

@ThomasGreenspan would you mind updating the jsdom version in the issue title to latest (v26.0.0)?
This would also get rid of the issue @it11ah1 mentioned, which is a thing if you used the latest @angular/cdk

@ThomasGreenspan ThomasGreenspan changed the title [Feature]: Upgrade jest-environment-jsdom dependency to jsdom@^25.0.1 [Feature]: Upgrade jest-environment-jsdom dependency to jsdom@^26.0.0 Jan 20, 2025
@SimenB
Copy link
Member

SimenB commented Jan 21, 2025

#15217 (comment)

@andreibereczki
Copy link

#15473

@andreibereczki
Copy link

andreibereczki commented Jan 21, 2025

If the reason for closing is that jest doesn't want to drop support for node@16 ... then how come this could be a thing: #15461
And if that's not the reason, then @SimenB please give more details as to why this feature request has been closed?
Especially given the fact that a PR is already open for the topic.

@andreibereczki
Copy link

Hi all, not sure if the jest package maintainers will approve / merge my PR (due to several breaking changes).

I built a custom jest environment in the meantime to help us all out.

Feel free to play around with it: https://github.com/andreibereczki/jest-environment-jsdom-twentysix

If something doesn't work, please drop me a message and i'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests