Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12201

How to mock axios.create() with Jest?

$
0
0

Here is my Axios definition:

import axios from "axios";import { API_ENDPOINT } from "@env";// axios settingexport const axiosInstance = axios.create({  withCredentials: true,  baseURL: API_ENDPOINT,});

I tried this but it doesn't work. Got this error: Property mockResolvedValueOnce does not exist on type.

jest.mock("@/lib/axios", () => ({  axiosInstance: {    get: jest.fn(),    patch: jest.fn(),  },}));axiosInstance.get.mockResolvedValueOnce(  {    data: {      test: 1    } })

Viewing all articles
Browse latest Browse all 12201

Trending Articles