[Vuejs]-How do I test if my data changes? (Vue JS, Jest, Unit Testing)

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

Leave a comment