TypeError: _axios.default.get.mockResolveValue is not a function
来源:3-2 mock 深入学习

gakeez
2021-05-01
- demo.js
import axios from "axios";
export const fetchData = () => {
return axios.get("/").then((res) => res.data);
};
- demo.test.js
import { fetchData } from "./demo";
import Axios from "axios";
jest.mock("axios");
test("fetchData 测试", () => {
Axios.get.mockResolveValue({
data: "function(){return '123'})()",
});
return fetchData().then((data) => {
expect(eval(data)).toEqual("123");
});
});
- 报的错误
- 检查过代码,应该没写错吧。安装的插件也是和课程同步的,不知道是什么问题
写回答
1回答
-
Dell
2021-05-01
同学,你 jest 官方网站上搜索下,这个API 还是否存在了
032021-06-20
相似问题