HomeToolsAbout a20k

Queries

What is it

Methods to find elements on page

import {render, screen} from "@testing-library/react" test('should show login form', () => { render(<TestingComponent />) const input = screen.getByLabelText("username"); // assertions })

Query Types

// single element getBy() // error on 0 match queryBy() // null on 0 match findBy() // error on 0 match // multiple element (returns array) getAllBy() // error on 0 match queryAllBy() // [] on 0 match findAllBy() // error on 0 match
© VincentVanKoh