We've recently been asked a question on how to successfully unit test $sessionStorage within AngularJS controllers.
We've used both $sessionStorage and $localStorage within AngularJS controllers without the need for mocking them during unit testing but in some cases it's useful to be able to do so.
We've created a quick jsfiddle to demonstrate how to successfully mock $sessionStorage ($localStorage would also work in the same way) within your AngularJS controllers.
Subscribe to Scriptwerx
Get the latest posts delivered right to your inbox