Loading tutorials
test, expect, and describe from Jest or Vitest. You should also be comfortable with async/await. By the end you will have a working test environment and a passing smoke test. Later chapters build on 5 min readrender, which mounts a component into a DOM, and screen, which queries what was mounted. It looks at what render does, what it returns, and when you should not use those return values.5 min readgetBy, queryBy, and findBy. They find elements the same way, but they differ in what they do when no element matches and in whether they wait. Picking the wrong variant gives you flaky tests, misleading failures, or assertions that can never5 min readscreen.getByX, queryByX, and findByX. It also assumes you know basic HTML semantics: which elements are buttons, links, headings, and form controls, and how a <label> connects to an input. If the query variants are unfamiliar, 5 min readrender, screen, and the getBy, queryBy, and findBy variants. It also assumes you know the query priority order (role, label, text, test ID). Here you will learn to read a failing query's output, inspect the DOM the 6 min readrender, screen, and getBy queries. It also assumes you know Jest or Vitest well enough to use expect, and that you know how HTML attributes like disabled, hidden, and aria-invalid work.4 min readscreen, and assert with jest-dom matchers. It also assumes you are comfortable with async/await. By the end you will be able to drive a component with realistic clicks, typing, keyboard navigation, and selection, and 5 min readrender, screen, role and label queries, and user-event work. Here you combine the5 min readtest, expect, describe). It also assumes you have read the earlier chapters on render, screen, query variants, and user-event.6 min readrender, screen, a getBy, findBy, or queryBy query, and user-event. It also assumes you know async/await and the basics of Jest or Vitest. Examples use Jest. Vitest differences are marked.5 min readrender, screen, and user-event. It also assumes you know React context, and that you have used a provider such as a router, a theme, a store, or a data-fetching client. You should also know how the wrapper option of render fits into a5 min readuseState, useEffect, and useContext do. The examples use Jest. In Vitest, replace jest.fn() with vi.fn() and import vi from vitest.4 min readscreen queries, simulate events with user-event, and write basic async tests with findBy and waitFor.5 min read