Created
February 6, 2019 00:14
-
-
Save bcherny/00dd36c7a53a45dba53a929dcc30c992 to your computer and use it in GitHub Desktop.
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
let called = false; | |
// this 'scope' is safe to interact with the React component, | |
// rendering and clicking as you please | |
await render( | |
<App | |
callback={() => { | |
called = true; | |
}} | |
/>, | |
document.body | |
); | |
// at this point, we can guarantee that effects have been executed, | |
// so we can make assertions | |
expect(called).toBe(true); // this passes now! | |
const button = document.getElementById('button'); | |
await dispatchEvent(button, new MouseEvent('click', {bubbles: true})) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment