Created
September 2, 2023 15:16
-
-
Save johnhunter/20e1cfbd5daf022d4cde6ab11a6c929c to your computer and use it in GitHub Desktop.
Test utility that augments testing-library with the user-event setup
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
import { render as renderComponent } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
type RenderArgs = Parameters<typeof renderComponent>; | |
export * from '@testing-library/react'; | |
/** | |
* Augments the RTL render with a userEvent user | |
*/ | |
export const render = (ui: RenderArgs[0], options?: RenderArgs[1]) => { | |
return { | |
...renderComponent(ui, options), | |
user: userEvent.setup(), | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment