-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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]: make jsdom accessible to extending environments again #12233
Comments
I thought about opening a PR and just making I'm not sure what the best way forward here is, but would be open to help out if someone could give some guidance? 🙇 |
We can do this for Jest 28 when we'll stop shipping the jsdom env by default (so any types it pulls it won't affect people who don't use it). I fixed the issue upstream anyways: DefinitelyTyped/DefinitelyTyped#57432 |
For anyone stumbling upon this:
// @ts-ignore
this.global.jsdom = this.dom; |
@robin-drexler feel free to send a PR reverting #12107 🙂 |
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. |
Version
27.4.7
Steps to reproduce
I prepared a small reproduction repository.
It uses a custom TS environment that tries to access
this.dom
and fails.To see for yourself:
npm install
npx jest
Expected behavior
Jest Environments that extend
jest-environment-jsdom
should be able to accessthis.dom
.Basically, this should work:
Actual behavior
That doesn't work if the project uses TypeScript because
this.dom
has recently been made private.The error you get if you try to access
this.dom
in an environment:Additional context
jest-environment-jsdom-global
(a popular npm package that uses the same technique to makejsdom
available) is currently unaffected because it uses JS and the transpiled CommonJS version ofjest-environment-jsdom
doesn't enforcethis.dom
to be private. Ifjest
changes its bundling process in the future, this could also fail for projects using JS.I think it'd be great if
jsdom
continued to be accessible for custom environments since that enables use cases that would otherwise not be possible.Environment
System: OS: macOS 12.1 CPU: (8) x64 Apple M1 Binaries: Node: 14.16.1 - /usr/local/bin/node Yarn: 2.4.3 - ~/.npm-global/bin/yarn npm: 7.11.2 - /usr/local/bin/npm
The text was updated successfully, but these errors were encountered: