// Greeting.jsx export default function Greeting({ name }) { return

Hello, {name}!

; } // Greeting.test.jsx import { render, screen } from "@testing-library/react"; import { describe, test, expect } from "vitest"; import Greeting from "./Greeting"; describe("Greeting", () => { test("renders the given name", () => { render(); expect(screen.getByText("Hello, Philip!")).toBeInTheDocument(); }); test("renders a different name correctly", () => { render(); expect(screen.getByText("Hello, Sam!")).toBeInTheDocument(); }); }); /* Notes: - Each test renders a fresh instance of Greeting with a different name prop — React Testing Library mounts a clean DOM for every test automatically. - getByText looks for the exact rendered text; if Greeting's output didn't match, the test would fail with a clear error rather than silently passing. */