make jsdom accessible to extending environments #12232
Merged
+4
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #12233
I initially wanted to create an issue, but thought it may be better if I opened a PR. Please let me know if you'd rather have me open an issue.
In f9814d2
dom
has been made private.This causes extending environments that depend on
this.dom
being available like jest-environment-jsdom-global to break if they use TypeScript.The error you get if you try to access
this.dom
in an environment: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
jest-environment-jsdom-global
itself is actually 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.