axios({method: "GET", url:"/something"})
如何模拟这种类型的Axios请求? 我正在一个React原生项目中使用jest进行测试(没有expo)
import axios from 'axios';
jest.mock('axios');
describe('fetchData', () => {
it('fetches successfully data from an API', async () => {
const data = {
data: {
},
};
axios.get.mockImplementationOnce(() => Promise.resolve(data));
});