-
-
Couldn't load subscription status.
- Fork 1.5k
Description
Describe the bug
In Node v25.0.0 released one week ago the Web Storage API is enabled by default (nodejs/node@3312e4e946 , nodejs/node#57666), of which the behavior is however different with the browser. Now localStorage in Node is no longer undefined. Test units with Vitest with either jsdom or happy-dom environment will fail to provide methods like localStorage.getItem. I'm not completely sure it's a bug from Vitest, but I guess it's some downstream software detects its existence and gives up mocking it up. With limited exploration I find jsdom has consistent behavior in Node v25 and Node v24, so I first post it here.
A workaround for people encountering the same error: Set an environment variable to disable Web Storage API: export NODE_OPTIONS="--no-webstorage".
Reproduction
I created a minimal reproduction here: https://github.com/simonmysun/node25-vitest
The demo.test.ts will fail with Node v25 and succeed with Node v24. The docker compose file might help if you already have such environment.
System Info
vitest/3.2.4. Any system with Nodejs v25.0.0Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.