Skip to content

Instantly share code, notes, and snippets.

@OlaoluwaM
Last active October 4, 2020 23:14
Show Gist options
  • Save OlaoluwaM/09116c472de2b98e40a7587a446754fb to your computer and use it in GitHub Desktop.
Save OlaoluwaM/09116c472de2b98e40a7587a446754fb to your computer and use it in GitHub Desktop.
act example snipper
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