React Testing Quiz
Test your knowledge of React Testing Library, component tests, queries, user events, async testing, and common testing practices.
20 questions · free · answers explained
All questions in this quiz
- What is the main goal of React Testing Library?
- Which function renders a React component in a React Testing Library test?
- What does screen provide in Testing Library?
- Which query is usually preferred for accessible buttons?
- Which query is appropriate when an element must exist immediately?
- Which query is useful when checking that an element is absent?
- Which query is commonly used for elements that appear asynchronously?
- What does user-event simulate better than a raw fireEvent call?
- Why should tests avoid relying heavily on CSS class names?
- Which assertion checks that an element is visible to the user?
- What should you usually assert in a component test?
- How should an async user-event interaction usually be handled?
- What is a common reason to mock an API request in a React test?
- Which query best matches a labeled form input from a user perspective?
- When should getByTestId usually be used?
- What does cleanup do in a React Testing Library environment?
- What is the purpose of waitFor?
- Why is testing accessibility roles useful?
- What should a test do before interacting with a button using user-event?
- Which test is more maintainable?
Prefer to read first? React interview questions with written answers.