【发布时间】:2022-02-28 06:49:36
【问题描述】:
当向 Jest 配置添加任何转换器或空属性转换时,模拟不起作用。下面是简单的代码。
笑话配置:
"transform": {
any regex: any transformer
}
模块说:
module.exports = (m) => {
console.log(m);
};
模块测试模块:
const say = require("./say");
module.exports = () => {
say("Hello world!");
};
测试:
jest.mock("./say", () => () => console.log("Mock!!!!"));
test("any test", () => {
});
如果删除转换配置,模拟工作,将得到消息:模拟!!!!!!。
【问题讨论】: