loading...

re: Testing Svelte stores and mocking dependencies VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Can you please offer some insight into how to make the localStorage available on the global window? I import stores into my components, but they a...
 

What version of JSDOM are you using? The latest version has an implementation of localStorage ready to go, I think.

You can also use spies but I wouldn’t bother with using a package for it (although that’s what I say about everything to be fair, so ymmv 🤷‍♂️)

Here’s an example of how I used spies to test local storage in a React codebase (with Jest):

github.com/PacktPublishing/Masteri...

 

So now I need to learn Jest or does Jasmine have spies, also I guess I need to find out what spies are lol.

I'm using whatever JSDOM you had in your dependency tree. I copied them out.

Jasmine has spies - jasmine.createSpy

I’ll see if I can port across the local storage tests to Svelte a little later today.

Code of Conduct Report abuse