capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.14k stars 189 forks source link

Property localStorage is not defined in Vitest using happy-dom@14.1.1 #1339

Closed ottomated closed 4 months ago

ottomated commented 4 months ago

Describe the bug Prior to 14.1.1, global uses of localStorage would work as expected. They no longer do.

To Reproduce See codesandbox repro

Expected behavior Global uses of window globals should work as expected.

Device: All

capricorn86 commented 4 months ago

Thank you for reporting @ottomated! :slightly_smiling_face:

I'm trying to reproduce the problem, but it seems like it is working in my environment.

I can't access the codesandbox. Is it possible for you to change permission?

capricorn86 commented 4 months ago

It seems like it is working here: https://stackblitz.com/edit/stackblitz-starters-ghue6z?file=index.js

ottomated commented 4 months ago

Updated permissions

capricorn86 commented 4 months ago

@ottomated thank you for updating permissions.

There is a fix in now that solves the problem: https://github.com/capricorn86/happy-dom/releases/tag/v14.1.2

I described the problem and solution in the release notes:

ottomated commented 4 months ago

Thanks for the quick fix!