Meu arquivo de teste contendo o código abaixo está retornando TypeError: _useList.default.mockReturnValue is not a function
ao executar npm test
import { render, screen } from "@testing-library/react";
import React from "react";
import { RecoilRoot } from "recoil";
import useList from "../../state/hooks/useList";
import List from "./List";
jest.mock("../../state/hooks/useList", () => {
return {
useList: jest.fn()
}
})
describe("empty list", () => {
beforeEach(() => {
(useList as jest.Mock).mockReturnValue([])
})
test("should be rendered", () => {
render(
<RecoilRoot>
<List />
</RecoilRoot>
)
const items = screen.queryAllByRole("listitem")
expect(items).toHaveLength(0)
})
})
describe("not empty list", () => {
const participants = ["Ana", "Beatriz"]
beforeEach(() => {
(useList as jest.Mock).mockReturnValue(participants)
})
test("should be rendered", () => {
render(
<RecoilRoot>
<List />
</RecoilRoot>
)
const items = screen.queryAllByRole("listitem")
expect(items).toHaveLength(participants.length)
})
})