Jest + PopOvers mock

  1. document.createRange reference
    • allows a jsdom env test to mock popovers / popups
    • for error TypeError: document.createRange is not a function
  2. 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),
});