Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created September 2, 2023 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhunter/20e1cfbd5daf022d4cde6ab11a6c929c to your computer and use it in GitHub Desktop.
Save johnhunter/20e1cfbd5daf022d4cde6ab11a6c929c to your computer and use it in GitHub Desktop.
Test utility that augments testing-library with the user-event setup
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