Running mocha gives error 'ReferenceError: sessionStorage is not defined'
<p>I am setting up Mocha for my ReactJs app (in ES6 format mostly).</p>

<p>On running the test using <code>"test": "mocha --compilers js:babel-register --recursive"</code> setup in package.json I get the following output:</p>

<pre><code>purezen_@mb ~/workspace/webapp (Test-Setup●●)$ npm test

&gt; webapp@0.1.0 test /Users/purezen_/workspace/webapp
&gt; mocha --compilers js:babel-register --recursive

/Users/purezen_/workspace/webapp/src/js/data/reducers/auth.js:31
var auth = sessionStorage.getItem('auth');
           ^

ReferenceError: sessionStorage is not defined
    at Object.&lt;anonymous&gt; (auth.js:5:14)
    at Module._compile (module.js:397:26)
    at loader (/Users/purezen_/workspace/kredx-fe/client/node_modules/babel-register/lib/node.js:158:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/purezen_/workspace/webapp/node_modules/babel-register/lib/node.js:168:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.&lt;anonymous&gt; (index.js:5:1)
    at Module._compile (module.js:397:26)
    at loader (/Users/purezen_/workspace/webapp/node_modules/babel-register/lib/node.js:158:5)
</code></pre>

<p><strong>test/actions/actions.spec.js</strong></p>

<pre><code>import configureMockStore from 'redux-mock-store'
import createSagaMiddleware from 'redux-saga'
import sagas from 'data/sagas'
import nock from 'nock'
import expect from 'expect'

(function (glob) {
    function mockStorage() {
        var storage = {};
        return {
            setItem: function(key, value) {
                storage[key] = value || '';
            },
            getItem: function(key) {
                return storage[key];
            },
            removeItem: function(key) {
                delete storage[key];
            },
            get length () {
                return Object.keys(storage).length;
            },
            key: function(i) {
                var keys = Object.keys(storage);
                return keys[i] || null;
            }
        };
    }
    glob.localStorage = mockStorage();
    glob.sessionStorage = mockStorage();
}(typeof window !== 'undefined' ? window : global));

const sagaMiddleware = createSagaMiddleware(sagas)
const middlewares = [ sagaMiddleware ]
const mockStore = configureMockStore(middlewares)
// const storeWithMiddleware = applyMiddleware(middlewares)(mockStore)

console.log(mockStore)
</code></pre>

<p>I have tried to implement a mock session storage in the spec file, but that doesn't seem to help.</p>

<p>EDIT: Here's my auth.js as requested in the comments</p>

<pre><code>import * as c from 'data/constants'
import {Map} from 'immutable'

// Load auth details from session storage
const auth = sessionStorage.getItem('auth');
const defaultState = Map(JSON.parse(auth));

export default function (state=defaultState, action) {
  const { type, payload} = action
  switch (type) {
    case c.SET_AUTH: {
      return Map(payload)
    }
  }
  return state;
}
</code></pre>