File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ facilitate testing implementation details). Read more about this in
86
86
* [ ` cleanup ` ] ( #cleanup )
87
87
* [ ` Simulate ` ] ( #simulate )
88
88
* [ ` wait ` ] ( #wait )
89
+ * [ ` waitForElement ` ] ( #waitforelement )
89
90
* [ ` fireEvent(node: HTMLElement, event: Event) ` ] ( #fireeventnode-htmlelement-event-event )
90
91
* [ ` TextMatch ` ] ( #textmatch )
91
92
* [ ` query ` APIs] ( #query-apis )
@@ -373,6 +374,39 @@ The default `interval` is `50ms`. However it will run your callback immediately
373
374
on the next tick of the event loop (in a ` setTimeout ` ) before starting the
374
375
intervals .
375
376
377
+ ### ` waitForElement `
378
+
379
+ See [dom - testing - library #waitForElement ](https :// github.com/kentcdodds/dom-testing-library#waitforelement)
380
+
381
+ ` ` ` js
382
+ await waitForElement(() => getByText('Search'))
383
+ ` ` `
384
+
385
+ <details >
386
+ <summary >
387
+ Example
388
+ < / summary >
389
+
390
+ ` ` ` diff
391
+ test('should submit form when valid', async () => {
392
+ const mockSubmit = jest.fn()
393
+ const {
394
+ container,
395
+ getByLabelText,
396
+ getByText
397
+ } = render(<Form onSubmit={mockSubmit} />)
398
+ const nameInput = getByLabelText('Name')
399
+ nameInput.value = 'Chewbacca'
400
+ Simulate.change(nameInput)
401
+ + // wait for button to appear and click it
402
+ + const submitButton = await waitForElement(() => getByText('Search'))
403
+ + Simulate.click(submitButton)
404
+ + expect(mockSubmit).toBeCalled()
405
+ })
406
+ ` ` `
407
+
408
+ < / details >
409
+
376
410
### ` fireEvent(node: HTMLElement, event: Event) `
377
411
378
412
Fire DOM events .
You can’t perform that action at this time.
0 commit comments