jest icon indicating copy to clipboard operation
jest copied to clipboard

[Feature]: Upgrade jest-environment-jsdom dependency to jsdom@^25.0.1

Open ThomasGreenspan opened this issue 1 year ago • 5 comments

🚀 Feature Proposal

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

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): https://github.com/jestjs/jest/issues/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.

ThomasGreenspan avatar Sep 27 '24 18:09 ThomasGreenspan

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 avatar Oct 02 '24 16:10 loucadufault

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).

loucadufault avatar Oct 02 '24 16:10 loucadufault

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 ...

davidagitlen avatar Oct 04 '24 19:10 davidagitlen

+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]

dmurvihill avatar Oct 06 '24 01:10 dmurvihill

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

lintu22 avatar Oct 16 '24 12:10 lintu22

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

jemunk avatar Oct 30 '24 12:10 jemunk

even renovate wants this https://github.com/jestjs/jest/pull/15276

tylerd-canva avatar Nov 17 '24 08:11 tylerd-canva

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.

brinehart avatar Dec 04 '24 18:12 brinehart

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[bot] avatar Jan 03 '25 19:01 github-actions[bot]

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

davidagitlen avatar Jan 03 '25 19:01 davidagitlen

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

it11ah1 avatar Jan 14 '25 13:01 it11ah1

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

andreibereczki avatar Jan 20 '25 15:01 andreibereczki

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).

ThomasGreenspan avatar Jan 20 '25 18:01 ThomasGreenspan

@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

andreibereczki avatar Jan 20 '25 19:01 andreibereczki

https://github.com/jestjs/jest/issues/15217#issuecomment-2254474396

SimenB avatar Jan 21 '25 11:01 SimenB

https://github.com/jestjs/jest/pull/15473

andreibereczki avatar Jan 21 '25 11:01 andreibereczki

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: https://github.com/jestjs/jest/pull/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 avatar Jan 21 '25 12:01 andreibereczki

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.

andreibereczki avatar Jan 22 '25 03:01 andreibereczki

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[bot] avatar Feb 22 '25 00:02 github-actions[bot]