Navigation Menu

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

fix(jest-environment-node): Add Event and EventTarget to node global #11727

Merged
merged 1 commit into from Aug 13, 2021

Conversation

jayphelps
Copy link
Contributor

@jayphelps jayphelps commented Aug 3, 2021

Summary

Adds Event and EventTarget to node global, if available (starting in Node 15.4+). Fixes #11705.

Test plan

No existing pattern of testing of exposing environment globals could be found, but one can can test it by trying to see if Event and EventTarget are available to node test environments: https://github.com/jayphelps/jest-event-demo

@@ -66,6 +66,14 @@ class NodeEnvironment implements JestEnvironment {
if (typeof AbortController !== 'undefined') {
global.AbortController = AbortController;
}
// Event is global in Node >= 15.4
if (typeof Event !== 'undefined') {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know maybe if there are tests that test other globals from this file?
If so it would make sense to have tests for this logic also.
Other than that, good catch and fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find any existing tests around making globals available. It's possible I missed them, but I was decently thorough.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@SimenB SimenB merged commit 9792b80 into jestjs:master Aug 13, 2021
@github-actions
Copy link

This pull request 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 Sep 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants