title: How to mock localStorage in JavaScript unit tests?
body: <p>Are there any libraries out there to mock <code>localStorage</code>?</p>
  
  <p>I've been using <a href="http://sinonjs.org/" rel="noreferrer" title="Sinon.JS">Sinon.JS</a> for most of my other javascript mocking and have found it is really great.</p>
  
  <p>My initial testing shows that localStorage refuses to be assignable in firefox (sadface) so I'll probably need some sort of hack around this :/</p>
  
  <p>My options as of now (as I see) are as follows:</p>
  
  <ol>
  <li>Create wrapping functions that all my code uses and mock those</li>
  <li>Create some sort of (might be complicated) state management (snapshot localStorage before test, in cleanup restore snapshot) for localStorage.</li>
  <li><code>??????</code></li>
  </ol>
  
  <p>What do you think of these approaches and do you think there are any other better ways to go about this?  Either way I'll put the resulting "library" that I end up making on github for open source goodness.</p>