Testimi & QA

Testing React components

Në shqip: Testimi i komponentëve React

ShpjegimiSQ

React Testing Library teston komponentët si përdoruesi: gjen elementet me getByRole ose getByText, klikon me userEvent dhe kontrollon çfarë shfaqet — jo state-in e brendshëm.

EnglishEN

React Testing Library tests components like a user: it finds elements with getByRole or getByText, clicks with userEvent and checks what's displayed — not internal state.

Si ta mendosh

Si të provosh telekomandën duke shtypur butonat, jo duke e hapur.

Lexoje në anglisht

Like testing a remote by pressing its buttons, not opening it up.

Shembull kodijavascript

render(<Numerues />);
await userEvent.click(screen.getByRole("button", { name: "+" }));
expect(screen.getByText("1")).toBeInTheDocument();

Terma të lidhur