rtl-simple-queries
rtl-simple-queries
是 React Testing Library
的一个配套库,它提供了一个替代的查询API。
- npm
- Yarn
npm install --save-dev rtl-simple-queries
yarn add --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})