react-firebase-hooks icon indicating copy to clipboard operation
react-firebase-hooks copied to clipboard

Mock `useDocumentDataOnce` with jest

Open RobertBrunhage opened this issue 3 years ago • 1 comments

I am using useDocumentDataOnce and trying to mock out the result but not being successful.

My understanding is that the first one is the data, second one is loading and the last one is the error, but this just makes the code get stuck in the test.

jest.mock("react-firebase-hooks/firestore", () => ({
  useDocumentDataOnce: () => [
    {
      name: test,
    },
    false, 
    null,
  ],
}));

RobertBrunhage avatar May 01 '21 17:05 RobertBrunhage

This link helped me out: https://stackoverflow.com/a/66091532/628699

imjared avatar Jul 13 '21 18:07 imjared

Closing as the linked stackoverflow answers this question

chrisbianca avatar Nov 04 '22 16:11 chrisbianca