Jest + PopOvers mock
ยท note
- document.createRange reference
- allows a jsdom env test to mock popovers / popups
- for error
TypeError: document.createRange is not a function
- createContextualFragment reference
- for error
TypeError: document.createRange(...).createContextualFragment is not a function
global.document.createRange = props => ({
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: {
nodeName: 'BODY',
ownerDocument: document,
},
createContextualFragment: str => JSDOM.fragment(str),
});