跳到主要内容

rtl-simple-queries

rtl-simple-queriesReact Testing Library 的一个配套库,它提供了一个替代的查询API。

npm install --save-dev rtl-simple-queries
import {screen} from 'rtl-simple-queries'

screen.fetchByText(/text/, {allowEmpty: true, allowMultiple: false})
screen.fetchByText(/text/, {allowMultiple: false})
screen.fetchByText(/text/)

// async
await screen.fetchByTextAsync(/text/, {allowMultiple: true})