Skip to content

Commit 9634269

Browse files
committed
Fix an issue w/ cleaning up global.document.
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
1 parent bdff1b8 commit 9634269

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ export function withSetStateAllowed(fn) {
221221
}
222222
fn();
223223
if (cleanup) {
224+
// This works around a bug in node/jest in that developers aren't able to
225+
// delete things from global when running in a node vm.
226+
global.document = undefined;
224227
delete global.document;
225228
}
226229
}

0 commit comments

Comments
 (0)