const axios = "axios";
jest.mock(axios);
axios.get.mockImplementation((url) => {
if(url === process.env.ENHANCED_CLAIM_STATUS_276_DETAILS){
return Promise.resolve({ status: 200, data: claim_response_276 });
}
if(url === process.env.ENHANCED_VALUE_ADDS_277_DETAILS){
return Promise.resolve({ status: 200, data: claim_response_277 });
}
});
我尝试模拟API响应,但它抛出此错误:
**TypeError: Cannot read properties of undefined (reading 'mockImplementation')**
1条答案
按热度按时间zpf6vheq1#
moduleName
参数应为字符串。请参见API文档jest.mock(模块名称、工厂、选项)工作示例:
试验结果: