Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
Something went wrong. Try again.
1.5 kB · 58 lines
TSX
at commit befbe0c4
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import { render, screen, userEvent } from '../utils/test-utils'import { Input } from './Input'
describe('Input', async () => { it('should render the input', () => { render( <Input name="email" type="email" error={undefined} placeholder="Email" label="Email Address" aria-label="Email Address" />, ) expect(screen.getByText('Email Address')).toBeInTheDocument() expect(screen.getByRole('textbox', { name: /email address/i, })).toBeInTheDocument() }) it('should change input value', async () => { render( <Input name="email" type="email" error={undefined} placeholder="Email" label="Email Address" aria-label="Email Address" />, )
screen.logTestingPlaygroundURL()
const input = screen.getByRole('textbox', { name: /email address/i, }) expect(input).toBeInTheDocument() await userEvent.type(input, '1337') expect(input).toHaveValue('1337') }) it('should render the input with error', () => { render( <Input name="email" type="email" placeholder="Email" label="Email Address" aria-label="Email Address" error="Please enter your email" />, ) expect(screen.getByRole('textbox', { name: /email address/i, })).toBeInTheDocument() expect(screen.getByRole('alert')).toHaveTextContent('Please enter your email') })})