import { ReactElement } from "react" ; import { unmountComponentAtNode } from "react-dom" ; import { configure } from "enzyme" ; import * as Adapter from "enzyme-adapter-react-16" ; configure ( { adapter : new Adapter ( ) } ) ; import { mount } from "enzyme" ; export default function createMount ( ) { let attachTo = window . document . createElement ( "div" ) ; attachTo . setAttribute ( "id" , "app" ) ; window . document . body . insertBefore ( attachTo , window . document . body . firstChild ) ; let mountWithContext = function ( node , mountOptions = { } ) { return mount ( node , { attachTo , ... mountOptions } ) ; } ; return [ mountWithContext , ( ) => { unmountComponentAtNode ( attachTo ) ; attachTo . parentNode && attachTo . parentNode . removeChild ( attachTo ) ; } ] ; }