Created
October 11, 2022 07:38
-
-
Save Lelith/ce1e1f435c636a4874a78a995c189115 to your computer and use it in GitHub Desktop.
react testing library userEvent
This file contains 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, 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