dwyl / learn-offline-first

:floppy_disk: You won't always have access to the internet ... Learn how to build web apps that can be used offline!
GNU General Public License v2.0
10 stars 1 forks source link

Testing localStorage #13

Open finnhodgkin opened 7 years ago

finnhodgkin commented 7 years ago

Hopefully this will be relatively straightforward but will add any findings here.

JSDOM doesn't include support for localStorage but there's a node library (node-localstorage) that seems to address this.

Update: To test the script correctly initialises both when there is localStorage and when there isn't we had to use the decache module to reset the require() of the front-end script.

finnhodgkin commented 7 years ago

node-localStorage worked perfectly. No problems here :smile:

finnhodgkin commented 7 years ago

Having some trouble combining our two test files into one test command because the global variable document is overriding the second set of tests.

Have found a potential module for this: multi-tape

Only 3 stars but will update if it works :+1:

Update: multi-tape wasn't really fit for purpose because it doesn't work with Istanbul coverage

nelsonic commented 7 years ago

@finnhodgkin see: https://www.npmjs.com/package/decache

finnhodgkin commented 7 years ago

Although this issue has been solved (testing localStorage), it relies on the multi-test-file global problem discussed above being solved first, (now in #15)