Last active
October 4, 2020 23:14
-
-
Save OlaoluwaM/09116c472de2b98e40a7587a446754fb to your computer and use it in GitHub Desktop.
act example snipper
This file contains hidden or 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
test('should do.....', () => { | |
/*Rest of the test*/ | |
act(() => { | |
// Event will cause state update and rerender in controlled input component | |
fireEvent.input(inputElement, {target: {value: '123'}}) | |
// 'act' will make sure updates are applied to the DOM | |
}) | |
// So our assertion work with with updated UI | |
expect(inputElement).toHaveValue("123") // true | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment