Как создать mock для axios create?

app.jsx

useEffect(() => {
   const axiosClient = axios.create({
      baseURL: `http://localhost:8000/api`,
   });
    
  axiosClient.get(`/categories/list`);
})

app.test.jsx

import App from "./app.jsx";
import axios from "axios";

jest.mock("axios");

test("should display app", async () => {

axios.get.mockImplementation((url) => {
   return Promise.resolve({
      data: [{ id: 1, name: "books" }],
   });
});

render(<App />);

expect(await screen.findByText("books")).toBeInTheDocument();
});

В итоге ошибка TypeError: Cannot read properties of undefined (reading 'get')

14 | axiosClient.get(/categories/list); | ^


Ответы (0 шт):