Skip to content

Node v25 breaks tests with Web Storage API #8757

@simonmysun

Description

@simonmysun

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.0

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions