Last active
February 28, 2018 09:48
-
-
Save vinaymavi/431f6c4ad043ea05f06dab6a76f133ec to your computer and use it in GitHub Desktop.
Jest + Enzyme mount a component that has query selector like `document.getElementById()`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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