
Explore testing a React application using Jest and React Testing Library, with guidance from official React docs; learn to test real applications and transfer testing knowledge to other frontend tech.
Set up a minimal npm project to run your first test with jest, installing node and npm, initializing the project, and running npm test to execute tests.
Learn how to write and run tests in jest using test and describe blocks, understand expect assertions and matchers, and structure tests for clear naming and debugging.
Learn how to test variables and functions in React using external values, importing from app code, and writing reliable assertions with multiple checks to avoid false positives.
Explains how to run functions before and after tests to keep tests isolated, using before each, after each, before all, and after all to prepare data and reset state.
Learn to run Jest tests selectively with test.only and test.skip, speeding up large suites, and set per-test or global timeouts (default five seconds) with jest.setTimeout.
Discover how to use jest matchers with expect to verify numbers, strings, and arrays, including toBe, toEqual, greater than, less than, less than or equal, toMatch with regex, and toContain.
Learn to test React apps with the React testing library, focusing on UI tests and avoiding internal states, then set up a React app and run npm test.
Learn how to test a React component with render, access getByText and debug, locate the hello text, and assert its existence in the UI.
Learn how to inspect a rendered react element and perform assertions using tag name and text content, and streamline tests with render utilities like getByTestId and debug.
Explore the three element selectors in React Testing Library—get by, query by, and find by—and when to use each, including test id for robust element selection.
Learn how to use fireEvent from React testing library to simulate user interactions in tests by selecting a DOM element and triggering events like clicks, then asserting outcomes.
Learn to add a text input with useState in a React component, update its value via onChange, and test interactions with React Testing Library and Jest by asserting rendered output.
Clone the React app from GitHub, install dependencies with npm, and run the frontend to prepare for testing; optionally set up a Django REST API to observe backend integration.
Test a React movie details component by asserting it renders a unique title and description with query by text.
Test and verify a React component's ratings feature by checking average rating with orange stars, number of ratings, and using test IDs and innerHTML checks.
Learn to test interactive mouse events in a React component by simulating hover over five star icons with fireEvent, verify highlighting via the purple class and reset on mouseout.
Test and verify a React movie form by passing props to populate title and description, distinguishing create versus update by movie id, and asserting input values via label queries.
Test how the app handles an empty movie form by disabling the create button and ensuring no api request triggers, using mock fetch and the fetch-mock package to simulate responses.
Test the parent component of a React app by rendering the app and mocking fetch. Validate loading and error states, and wrap state updates in act to handle data changes.
Learn to test error handling in a React app by simulating a 500 API failure, waiting for the loading state to disappear, and asserting the 'Error loading movies' message.
Test a React app by verifying the movie list renders after API calls, mocking responses, and confirming the new movie button opens the movie form.
Learn how to test clicking on movie headings to display the corresponding details by selecting multiple elements via test IDs, clicking headings, and asserting the correct description appears.
Explore next steps in testing your React app by extending tests for the movie list and login/logout toggle, and consult React Testing Library docs for broader coverage.
This course is not just a theory and bullet points about testing React. In this course, we test real application and you will gain not just knowledge but also practice.
We will focus on testing web application in React. I will explain why it's worth testing and what tools we should pick for testing react application. We will be talking about many different aspects of testing: Unit tests, integration tests, snapshots, test runner, describe, before and after tests, skip tests, loops, matchers, truthy and falsy, render component, fire event, mocking, fetching API, act, wait and many more. After this tutorial, you will be able to handle many obstacles with testing the dynamic applications in React. We will write a lot of different tests to cover different technics and ways to select certain elements and interact with them.
The first tool that we will learn will be Jest. I will show you how to run tests and write them. At this level, we will write tests without React application. We will focus on Jest only and use it as our test runner.
After we will know what is Jest and how it works, we will install our first application with React Testing Library. I will show you how that library works and what options do we have with it. We will render our components and we will trigger different events.
The main section of this tutorial will be testing the real React app. We will have a ready app, written in React and we will start using different technics to test our components. We will be using the newest trends in React like hooks with useState and useEffect. When you finish that chapter, you will know what kind of problems you might have when writing your own tests for React and more importantly, how to solve them with Jest and React Testing Library.