From 0a3498d93a66b49911b073db123f9daf2867e969 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Mon, 9 Apr 2018 19:37:00 -0700 Subject: [PATCH] Dispose document when tearing down JSDom environment --- packages/jest-environment-jsdom/src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/jest-environment-jsdom/src/index.js b/packages/jest-environment-jsdom/src/index.js index b6acdc4d4ab5..df345faabf4d 100644 --- a/packages/jest-environment-jsdom/src/index.js +++ b/packages/jest-environment-jsdom/src/index.js @@ -97,6 +97,8 @@ class JSDOMEnvironment { if (this.errorEventListener) { this.global.removeEventListener('error', this.errorEventListener); } + // Dispose "document" to prevent "load" event from triggering. + Object.defineProperty(this.global, 'document', {value: null}); this.global.close(); } this.errorEventListener = null;