Skip to content

Instantly share code, notes, and snippets.

@Lelith
Created October 11, 2022 07:38
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 Lelith/ce1e1f435c636a4874a78a995c189115 to your computer and use it in GitHub Desktop.
Save Lelith/ce1e1f435c636a4874a78a995c189115 to your computer and use it in GitHub Desktop.
react testing library userEvent
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
test('validates an E-Mail address', async () => {
const user = userEvent.setup();
render(<LoginForm />);
const emailInput = screen.getByLabelText('E-Mail', {selector: 'input'});
await user.type(emailInput, 'Homer.Simpson@mail.com');
expect(screen.queryByRole('alertdialog')).not.toBeInTheDocument();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment