I am trying to setup mocha for my reactjs app.
However, running the command mocha --compilers js:babel-register --recursive produces an error saying
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.<anonymous> (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)
even when I have included code to mock session storage inside the test file according to http://stackoverflow.com/q/11485420/1509855
Was able to get it working using https://github.com/letsrock-today/mock-local-storage.
This was a lifesaver! Thanks a ton @purezen
I used mock-local-storage to mock my sessionStorage. It was as simple as just installing with npm and running the test. No additional code needs to be written!!
How to do this?
It is not working for me.
Please help
Do I need to change any file?
Most helpful comment
Was able to get it working using https://github.com/letsrock-today/mock-local-storage.