Skip to content

Commit c19117d

Browse files
patrickhulcejrolfs
authored andcommitted
feat: also expose waitFor
1 parent 2cf56dd commit c19117d

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ All your favorite user-centric querying functions from **@testing-library/react*
3535

3636
```js
3737
const {webkit} = require('playwright') // or 'firefox' or 'chromium'
38-
const {getDocument, queries, wait} = require('playwright-testing-library')
38+
const {getDocument, queries, waitFor} = require('playwright-testing-library')
3939

4040
const {getByTestId, getByLabelText} = queries
4141

@@ -51,7 +51,7 @@ const $email = await getByLabelText($form, 'Email')
5151
// interact with playwright like usual
5252
await $email.type('[email protected]')
5353
// waiting works too!
54-
await wait(() => getByText($document, 'Loading...'))
54+
await waitFor(() => getByText($document, 'Loading...'))
5555
```
5656

5757
A little too un-playwright for you? We've got prototype-mucking covered too :)

lib/__tests__/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path'
22
import * as playwright from 'playwright'
3-
import {getDocument, queries, getQueriesForElement, wait, configure} from '..'
3+
import {getDocument, queries, getQueriesForElement, waitFor, configure} from '..'
44

55
describe('lib/index.ts', () => {
66
let browser: playwright.Browser
@@ -62,7 +62,7 @@ describe('lib/index.ts', () => {
6262
it('should use `wait` properly', async () => {
6363
const {getByText} = getQueriesForElement(await getDocument(page))
6464
// eslint-disable-next-line @typescript-eslint/no-misused-promises
65-
await wait(() => getByText('Loaded!'), {timeout: 7000})
65+
await waitFor(() => getByText('Loaded!'), {timeout: 7000})
6666
expect(await getByText('Loaded!')).toBeTruthy()
6767
}, 9000)
6868

lib/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,14 @@ export function wait(
134134
return waitForExpect(callback, timeout, interval)
135135
}
136136

137+
export const waitFor = wait
138+
137139
export function configure(options: Partial<IConfigureOptions>): void {
138140
if (!options) {
139141
return
140142
}
141143

142-
const { testIdAttribute } = options
144+
const {testIdAttribute} = options
143145

144146
if (testIdAttribute) {
145147
delegateFnBodyToExecuteInPage = delegateFnBodyToExecuteInPageInitial.replace(

0 commit comments

Comments
 (0)