我有一个带有useFetch钩子的功能组件:
function Foo(){
const { data, isPending, run } = useFetch(`http://localhost:8080/users`);
}我如何在这里模拟data而不执行API调用?useFetch钩子来自库反应-异步
发布于 2022-04-09 15:27:37
import React from "react";
import reactAsync from "react-async";
jest.mock('reactAsync');
it("test", async () => {
const data = []
const isPending = false
const run = null
reactAsync.useFetch.mockReturnValueOnce({ data, isPending, run });
});https://stackoverflow.com/questions/71809106
复制相似问题