Created
April 10, 2024 04:08
-
-
Save singhAmandeep007/15640f1346f2ae9218e202ad3173fa0b to your computer and use it in GitHub Desktop.
Mocking localStorage jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const localStorageMock: Storage = { | |
| getItem: jest.fn(), | |
| setItem: jest.fn(), | |
| removeItem: jest.fn(), | |
| clear: jest.fn(), | |
| length: 0, | |
| key: jest.fn() | |
| }; | |
| global.localStorage = localStorageMock; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment