Skip to content

Instantly share code, notes, and snippets.

@cpojer
Last active January 12, 2026 04:55
Show Gist options
  • Select an option

  • Save cpojer/e66f9a082021a82230f2595a6027f161 to your computer and use it in GitHub Desktop.

Select an option

Save cpojer/e66f9a082021a82230f2595a6027f161 to your computer and use it in GitHub Desktop.
diff --git a/lib/jsdom/browser/Window.js b/lib/jsdom/browser/Window.js
index 52d011cae61c3688ec64baa5cec411d55edbda9d..298d7ec8d2cc1ea5e974262b978e6041389900f7 100644
--- a/lib/jsdom/browser/Window.js
+++ b/lib/jsdom/browser/Window.js
@@ -507,8 +507,8 @@ function installOwnProperties(window, options) {
// [LegacyUnforgeable]:
window: { configurable: false },
document: { configurable: false },
- location: { configurable: false },
- top: { configurable: false }
+ location: { configurable: true },
+ top: { configurable: false },
});
@bbkfhq
Copy link

bbkfhq commented Jan 12, 2026

FYI this no longer seems to work on jsdom 27.4.0 (of course line numbers have changed, but I mean the patch in general doesn't work anymore). Despite setting configurable to true, I get Error: Not implemented: navigation (except hash changes).

Edit: Never mind. My issue was that I had a direct dependency against jsdom. I removed it from my own package and just use jest-environment-jsdom which internally depends on jsdom.

Then you need to create this patch file patches/jest-environment-jsdom++jsdom+26.1.0.patch

(This will patch the jsdom that is inside jest-environment-jsdom)

diff --git a/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/browser/Window.js b/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/browser/Window.js
index 52d011c..5b29f5a 100644
--- a/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/browser/Window.js
+++ b/node_modules/jest-environment-jsdom/node_modules/jsdom/lib/jsdom/browser/Window.js
@@ -507,7 +507,7 @@ function installOwnProperties(window, options) {
     // [LegacyUnforgeable]:
     window: { configurable: false },
     document: { configurable: false },
-    location: { configurable: false },
+    location: { configurable: true },
     top: { configurable: false }
   });

And run npx patch-package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment