Глава 43. Тестирование PRO: RTL, Vitest, Playwright

Зачем эта глава

Тестирование — признак профессиональной разработки. Минимум — проверка ключевого поведения, максимум — e2e тесты.

RTL + Vitest

JS
import { render, screen } from "@testing-library/react";

it("renders title", () => {
  render(<App />);
  expect(screen.getByText(/hello/i)).toBeTruthy();
});

E2E с Playwright

JS
import { test, expect } from "@playwright/test";

test("home page", async ({ page }) => {
  await page.goto("/");
  await expect(page.getByText("Главная")).toBeVisible();
});