问题
When trying to use ezymes mount
on a component that is rendering MaterialUI's Tooltip, there is an error stopping my tests:
TypeError: document.createRange is not a function
回答1:
To fix this I defined document.createRange
in my ./src/setupTest.js
if (global.document)
document.createRange = () => ({
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: {
nodeName: "BODY",
ownerDocument: document,
},
})
来源:https://stackoverflow.com/questions/51887552/jest-enzyme-document-createrange-is-not-a-function-on-mount