Skip to content

Instantly share code, notes, and snippets.

@vinaymavi
Last active February 28, 2018 09:48
Show Gist options
  • Save vinaymavi/431f6c4ad043ea05f06dab6a76f133ec to your computer and use it in GitHub Desktop.
Save vinaymavi/431f6c4ad043ea05f06dab6a76f133ec to your computer and use it in GitHub Desktop.
Jest + Enzyme mount a component that has query selector like `document.getElementById()`
import { mount} from 'enzyme';
beforeAll(()=>{
const div = document.createElement('div');
window.domNode = div;
document.body.appendChild(div);
})
test("Test component with mount + document query selector",()=>{
const wrapper = mount(<YourComponent/>,{ attachTo: window.domNode });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment