Updating to Jest 30 is Frustrating (it’s JSDOM)

It’s time to update from Jest 29 to 30 for me.
Except I can’t. At least not completely.

The Easy Part

They changed the snapshot files: the link in the header changed. I find short-links disturbing anyway.

– // Jest Snapshot v1, https://go…


This content originally appeared on DEV Community and was authored by Hauke T.

It's time to update from Jest 29 to 30 for me.
Except I can't. At least not completely.

The Easy Part

They changed the snapshot files: the link in the header changed. I find short-links disturbing anyway.

- // Jest Snapshot v1, https://goo.gl/fbAQLP
+ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

Then they removed some deprecated matcher aliases. (expect(fn).toBeCalled()expect(fn).toHaveBeenCalled()) It took a while but was manageable.

Then I got really confused when I found out some modules are not mocked anymore. As it turns out jest.mock("./path/to/module") is case-sensitive now.

The Hard Part

Jest updated JSDOM from Version 20 to 26.

It added show-stopping CSS-bugs for me (el.style.boxShadow = undefined became el.style.boxShadow === "undefined" instead of the expected el.style.boxShadow === ""), fixed them in Version 27 and introduced new show-stopping CSS-bugs for me.

While this is manageable, my tests regarding navigation began to fail...

The impossible Part

JSDOM does not implement window.location which is fine.
Up until now it was possible to mock window.location, but this stopped working in JSDOM v21.

// does not work anymore
delete window.location;
Object.defineProperty(window, 'location', { // TypeError: Cannot redefine property: location
  writable: true,
  value: { search: '' },
});

Possible workarounds are discussed, but none are satisfactory.

The "Solution"

So at this point its Jest 30 with JSDOM 20 (from Jest 29). 🤮

// package.json
{
    // ...
    "devDependencies": {
        "jest": "^30.2.0",
        "jest-environment-jsdom": "^29.7.0",
    }
}

Uh and on the End-To-End test side, things became complicated since chrome complains when websites try to connect to localhost and local ip-adresses.

Testing is a nightmare right now.


This content originally appeared on DEV Community and was authored by Hauke T.


Print Share Comment Cite Upload Translate Updates
APA

Hauke T. | Sciencx (2025-11-10T11:09:13+00:00) Updating to Jest 30 is Frustrating (it’s JSDOM). Retrieved from https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/

MLA
" » Updating to Jest 30 is Frustrating (it’s JSDOM)." Hauke T. | Sciencx - Monday November 10, 2025, https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/
HARVARD
Hauke T. | Sciencx Monday November 10, 2025 » Updating to Jest 30 is Frustrating (it’s JSDOM)., viewed ,<https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/>
VANCOUVER
Hauke T. | Sciencx - » Updating to Jest 30 is Frustrating (it’s JSDOM). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/
CHICAGO
" » Updating to Jest 30 is Frustrating (it’s JSDOM)." Hauke T. | Sciencx - Accessed . https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/
IEEE
" » Updating to Jest 30 is Frustrating (it’s JSDOM)." Hauke T. | Sciencx [Online]. Available: https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/. [Accessed: ]
rf:citation
» Updating to Jest 30 is Frustrating (it’s JSDOM) | Hauke T. | Sciencx | https://www.scien.cx/2025/11/10/updating-to-jest-30-is-frustrating-its-jsdom/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.