Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jest mockedCoeus.mockedImplementation抛出一个TypeError_Javascript_Node.js_Typescript_Jestjs_Ts Jest - Fatal编程技术网

Javascript Jest mockedCoeus.mockedImplementation抛出一个TypeError

Javascript Jest mockedCoeus.mockedImplementation抛出一个TypeError,javascript,node.js,typescript,jestjs,ts-jest,Javascript,Node.js,Typescript,Jestjs,Ts Jest,我正在使用Jest编写一个测试并模拟一个调用HTTP请求的函数 import { mocked } from "ts-jest/utils"; import * as pull from "../src/pull"; import fs = require("fs"); // read the reponse data from a file. const response = JSON.parse( fs.readFileSync("./__fixtures__/pr.json", "u

我正在使用Jest编写一个测试并模拟一个调用HTTP请求的函数

import { mocked } from "ts-jest/utils";
import * as pull from "../src/pull";
import fs = require("fs");

// read the reponse data from a file.
const response = JSON.parse(
  fs.readFileSync("./__fixtures__/pr.json", "utf8")
);

// have jest mock the function and set it's response.
jest.mock("../src/pull");
const mockedCoeus = mocked(pull.getPullRequest, true);

mockedCoeus.mockImplementation(async () => {
  return response as any;
});

// write the test.
describe("#get details for a PR", () => {
  it("should load user data", async () => {
    const data = await pull.getPullRequest(165, "data-ios");
    expect(data).toBeDefined();
    expect(data.updated_at).toEqual("2020-04-10T16:46:30Z");
  });
});
但是,测试通过了,当运行
npmjest

TypeError: mockedCoeus.mockImplementation is not a function
我已经查看了其他报告的错误,这些错误与
jest.mock
的位置有关,但是,这里的情况似乎不是这样。为什么会抛出此错误,但测试通过了?我怎样才能修好它