sinon-chai

karma-sinon-chai fails after moving to Windows

那年仲夏 提交于 2019-12-11 20:36:14
问题 I have unit tests running under Karma, and am using the sinon-chai library. Everything was working fine on Mac, but now I have moved to Windows the following error is occuring: C:\Users\mchambe4\dev\simple\client>node ./node_modules/gulp/bin/gulp.js unit-tests-dev [16:29:31] Using gulpfile ~\dev\simple\client\gulpfile.js [16:29:31] Starting 'unit-tests-dev'... [16:29:31] Starting Karma server... WARN [karma]: Port 9876 in use INFO [karma]: Karma v0.12.37 server started at http://localhost

How to unit test localStorage using sinon

好久不见. 提交于 2019-12-06 01:57:39
I am trying to test localStorage using sinon. Basically I am very new to unit testing so this might be very basic. Update I managed to come up with this but now its giving me a new error Should wrap property of object Test describe('Initial State', () => { it('should set the initial state for the component', () => { const props = { currentUser: {} }; sinon.stub(window.localStorage, 'setItem'); window.localStorage.setItem('none', 'nothing'); }); }); Umair Sarfraz I managed to resolve it. Thanks to @anoop because his answer was of help but I had to manage it with a major workaround. I am using