简体   繁体   中英

What would be a proper way of integration testing JavaScript interacting with local storage?

After listening to the JavaScript Weekly podcast, where I heard about the jQueryLocalStorageTexteareas plugin, I decided to try to implement this myself.

What it basically does is save a textarea's content to the browser's local storage if supported by the browser.

My question is, how would I write this in a TDD style? How would the highest level test implementation look like? It should probably be something like

when I type foo in a text area
and I close the page
and I open it again
then the text area should contain foo

Is it worth using something like Selenium to implement these kind of tests? Or is there a better way to do it?

Use a testing framework built for the job, such as qUnit. jQuery-offline uses it to good effect to test caching of text using localStorage for browsers with and without native support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM