Assert behavior: Use expect() to check the outcome, like whether an element is?
rendered or a function is called.
Example of a simple unit test:
import { render, screen, fireEvent } from '@testing-library/react';
import Counter from './Counter';
test('increments counter on button click', () => {
render(<Counter />);
const button = screen.getByText('Increment');
fireEvent.click(button);
expect(screen.getByText('1')).toBeInTheDocument();
});
In this test, you: