1๐
I think you only need to mock this localStorage.getItem();
.
Mock it to return a dummy user id and then you simply run the test and check that the outcome is what you expect.
Seems like that is the only dependency you need to mock.
Something like:
global.localStorage = {
getItem: jest.fn(() => 'some user id')
};
๐คT. Short
- [Vuejs]-Pause functions on page history forward backward
- [Vuejs]-Vuejs can't get vuex value in navbar
Source:stackexchange.com