Forum

[Solved] NativeModule: AsyncStorage is null

0
Topic starter

While running test cases, faced an issue related to AsyncStorage/LagacyStorage from StorageProvider. 

[Please refer to the attached screenshot]

1 Answer
1
Topic starter

Add the below code to the test-setup.js file of your relevant block.

jest.mock("../../framework/src/StorageProvider", () => ({
  get: jest
    .fn()
    .mockImplementationOnce((key) => {
      if (key === "token") return "0";
      return "token";
    })
    .mockImplementation(() => null),
  set: jest.fn(),
}));