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 an issue w/ cleaning up global.document. #855

Merged
merged 1 commit into from
Mar 24, 2017

Conversation

gdborton
Copy link
Contributor

Except in the most recent versions of node, developers are unable to delete
things from global when running code in a node vm. This means that enzyme is
failing to clean up after itself when temporarily defining global.document for
setState calls.

This papers over the issue by explicitly setting global.document to undefined
if it failed to be deleted.

Relevant jest issue - jestjs/jest#3152

Relevant node pr - nodejs/node#11266

Copy link
Collaborator

@wyattdanger wyattdanger left a comment

Choose a reason for hiding this comment

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

LGTM

src/Utils.js Outdated
@@ -222,6 +222,11 @@ export function withSetStateAllowed(fn) {
fn();
if (cleanup) {
delete global.document;
// This works around a bug in node/jest in that developers aren't able to
Copy link
Member

Choose a reason for hiding this comment

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

can this be done before deleting it, so that it's always set to undefined, and then deleted when possible?

Except in the most recent versions of node, developers are unable to delete
things from global when running code in a node vm.  This means that enzyme is
failing to clean up after itself when temporarily defining global.document for
setState calls.

This papers over the issue by explicitly setting global.document to undefined
before attempting to delete. If the delete succeeds, the undefined value will
be removed.

Relevant jest issue - jestjs/jest#3152

Relevant node pr - nodejs/node#11266
@gdborton gdborton merged commit 67e6384 into enzymejs:master Mar 24, 2017
@gdborton gdborton deleted the fix-global-deletion branch March 24, 2017 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants