import { JSDOM } from 'jsdom' ; import * as React from 'react' ; import { render } from 'react-dom' ; export function withElement ( Component , f ) { let { window : { document } } = new JSDOM ; let div = document . createElement ( 'div' ) ; render ( < Component />, div); f ( div ) ; }