Complete the code to import the render function from React Testing Library.
import { [1] } from '@testing-library/react';
mount or shallow which are from Enzyme, not React Testing Library.fireEvent instead of render.The render function is used to render React components in tests.
Complete the code to query a button element by its role.
const { getByRole } = render(<button>Click me</button>);
const button = getByRole([1]);"link" or "textbox" which do not match a button.The role for a button element is "button". This helps find the button in the test.
Fix the error in the test by completing the assertion to check if the button is in the document.
expect(button).[1]();toBeNull() which checks for absence.toHaveTextContent() which checks text, not presence.The matcher toBeInTheDocument() checks if the element exists in the rendered output.
Fill both blanks to simulate a user click event on the button.
import { render, [1] } from '@testing-library/react'; const { getByRole } = render(<button>Click me</button>); [2].fireEvent.click(getByRole('button'));
userEvent without importing it properly.simulate which is from Enzyme, not React Testing Library.fireEvent is imported and used to simulate events like clicks in React Testing Library.
Fill all three blanks to write a test that renders a component, finds a button by role, and checks if it is enabled.
import { [1] } from '@testing-library/react'; const { [2] } = [3](<button>Submit</button>); expect(getByRole('button')).toBeEnabled();
screen without importing or destructuring properly.getByRole as a function to import directly.We import render, destructure getByRole from the render result, and call render to render the component.