localStorage is not being resolved sometimes
See original GitHub issuewhen i’m using localStorage.getItem
in before
function to get some user data from storage sometimes (randomly) it is not being resolved by test engine so it spews error Uncaught TypeError: Cannot read property 'getItem' of null
to fix this use window.localStorage.getItem
i can’t provide steps to reproduce or other useful info so i believe this bug will be closed soon but i’m posting this workaround for guys who has the same issue so they can google for answer
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top Results From Across the Web
localStorage is not working on google chrome
LocalStorage supports only string values, not boolean or others. Method to store and retrieve values: Put the value into storage
Read more >[solved] localStorage.setItem not working on the js file, but ...
This might be an issue of when the data is saved. The script will save it immediately when the page loads, but if...
Read more >React localStorage: set and get items with hooks
Learn the basics of React localStorage. In this tutorial, we'll focus on how to use the localStorage storage type with React and hooks....
Read more >LocalStorage, sessionStorage
The localStorage is shared between all windows with the same origin, so if we set the data in one window, the change becomes...
Read more >jQuery click function with localStorage not working (may be!)
theme-item .btn').attr('aria-pressed', 'true');. So, you're saying that if the color is supposed to be ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And where is the
localStorage.getItem
being called that you said is throwing the error in the context of the tests above?@Uzlopak the problem is i’m doing this in app, not in tests. App knows nothing about
cy.window()
and it should not Probably I should mock my global object akawindow
to usecy.window()
. but when i usewindow.localStorage
it works, so i dont need to mock it