Created
July 2, 2024 23:05
-
-
Save levchenkod/8bd4be266608704e29d5c2b8764a17c4 to your computer and use it in GitHub Desktop.
Mock useSWRInfinite with 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
import useSWRInfinite from "swr/infinite"; | |
jest.mock("swr/infinite"); | |
describe("Page with SWRInfinite", () => { | |
it("renders", () => { | |
(useSWRInfinite as jest.Mock).mockResolvedValue({ | |
data: [{ data: [] }], | |
error: null, | |
}); | |
//... | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment