尝试使用酵素时 mount
在呈现 MaterialUI 工具提示的组件上,停止我的测试时出错:TypeError: document.createRange is not a function
最佳答案
为了解决这个问题,我定义了 document.createRange
在我的 ./src/setupTest.js
document.createRange = () => ({
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: {
nodeName: "BODY",
ownerDocument: document,
},
})
关于reactjs - Jest/Enzyme document.createRange 不是挂载函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51887552/