xxxxxxxxxx
import { render, screen } from '@testing-library/react';
import YourComponent from './YourComponent';
test('renders YourComponent', () => {
render(<YourComponent />);
const element = screen.getByText('Hello, World!');
expect(element).toBeInTheDocument();
});
xxxxxxxxxx
// Quickstart (Hello World) with React Testing Library:
import { render, screen } from '@testing-library/react';
test('should show login form', () => {
render(<Login />); // Render the Component
const input = screen.getByLabelText('Username');
// Events and assertions....
expect( input ).not.toBeDisabled();
});
// Shout-out to @andreas-assehn and @kelott for the suggestion. :)