I am currently testing a login function where the user_id of the logged in user should be added to localStorage. However, i am unable to test this because of an uncaught reference error: "localStorage is not defined" Could somebody help me figure this out? Have tried 'mocking' localStorage without succes. Using mocha and chai for testing.
// Test if user_id is added to localstorage
it('should add user_id to localstorage', (done) => {
chai.request(app)
.post('/login')
.send({
username: 'admin',
password: '1234'
})
.end((err, res) => {
expect(localStorage.getItem('user_id')).to.equal('1');
done();
}
);
}
);