React Testing Library | _best_

expect(handleSubmit).toHaveBeenCalledWith({ email: 'test@example.com', password: 'password123' }) }) import { renderHook, act } from '@testing-library/react' test('useCounter hook increments', () => { const { result } = renderHook(() => useCounter(0))

// Logout await userEvent.click(screen.getByRole('button', { name: /logout/i })) expect(screen.getByRole('button', { name: /login/i })).toBeInTheDocument() }) react testing library

// Wait for loading to complete expect(screen.getByText(/loading/i)).toBeInTheDocument() expect(handleSubmit)