@@ -9,6 +9,16 @@ well as these methods:
9
9
10
10
- [ ` render ` ] ( < (#render) > )
11
11
12
+ Some of the ` DOM Testing Library ` re-exports are patched to work easier with
13
+ Angular:
14
+
15
+ - The events on ` fireEvent ` automatically invoke a change detection cycle after
16
+ the event has been fired
17
+ - The ` findBy ` queries automatically invoke a change detection cycle before the
18
+ query is invoked function
19
+ - The ` waitFor ` functions automatically invoke a change detection cycle before
20
+ invoking the callback function
21
+
12
22
## ` render `
13
23
14
24
``` typescript
@@ -189,6 +199,20 @@ const component = await render(AppComponent, {
189
199
})
190
200
` ` `
191
201
202
+ ### ` removeAngularAttributes `
203
+
204
+ Removes the Angular attributes (ng - version , and root - id ) from the fixture .
205
+
206
+ ** default ** : ` false `
207
+
208
+ ** example ** :
209
+
210
+ ` ` ` typescript
211
+ const component = await render(AppComponent, {
212
+ removeAngularAttributes: true,
213
+ })
214
+ ` ` `
215
+
192
216
## Directive RenderOptions
193
217
194
218
To test a directive , the render API is a bit different . The API has the same
@@ -244,11 +268,11 @@ component.debug(component.getByRole('alert'))
244
268
245
269
### ` rerender `
246
270
247
- Re - render the same component with different props .
248
- Will call ` detectChanges ` after props has been updated .
271
+ Re - render the same component with different props . Will call ` detectChanges `
272
+ after props has been updated .
249
273
250
274
` ` ` typescript
251
- const component = await render(Counter, { componentProperties: { count: 4 }})
275
+ const component = await render(Counter, { componentProperties: { count: 4 } })
252
276
253
277
expect(component.getByTestId('count-value').textContent).toBe('4')
254
278
@@ -258,11 +282,11 @@ expect(component.getByTestId('count-value').textContent).toBe('7')
258
282
259
283
### ` fireEvent.*** `
260
284
261
- The second most important feature of ` render ` is that the events from
262
- [DOM Testing Library ](https :// testing-library.com/docs/dom-testing-library) are
263
- automatically bound to the Angular Component . This to ensure that the Angular
264
- change detection has been run by calling ` detectChanges ` after an event has been
265
- fired .
285
+ The ` fireEvents ` re - exported from
286
+ [DOM Testing Library ](https :// testing-library.com/docs/dom-testing-library) that
287
+ are automatically bound to the Angular Component . This to ensure that the
288
+ Angular change detection has been run by invoking ` detectChanges ` after an event
289
+ has been fired .
266
290
267
291
See
268
292
[Firing Events ](https :// testing-library.com/docs/dom-testing-library/api-events)
@@ -281,6 +305,12 @@ component.change(component.getByLabelText('Username'), {
281
305
component.click(component.getByText('Login'))
282
306
` ` `
283
307
308
+ ### ` debugElement `
309
+
310
+ The Angular ` DebugElement ` of the component .
311
+
312
+ For more info see the [Angular docs ](https :// angular.io/api/core/DebugElement).
313
+
284
314
### ` fixture `
285
315
286
316
The Angular ` ComponentFixture ` of the component .
@@ -355,23 +385,19 @@ component.type(component.getByLabelText('Username'), 'Tim')
355
385
component.type(component.getByLabelText('Username'), 'Tim', { delay: 250 })
356
386
` ` `
357
387
358
- ### ` waitForDomChange `
359
-
360
- Wait for the DOM to change .
361
- For more info see the [DOM Testing Library docs ](https :// testing-library.com/docs/dom-testing-library/api-async#waitfordomchange).
362
-
363
- This function will also call `detectChanges` repeatably to update the DOM, is helpful to test async functionality.
364
-
365
- ### `waitForElement`
388
+ ### ` waitFor `
366
389
367
- Wait for DOM elements to appear, disappear, or change.
368
- For more info see the [DOM Testing Library docs](https : // testing-library.com/docs/dom-testing-library/api-async#waitforelement).
390
+ When in need to wait for any period of time you can use waitFor , to wait for
391
+ your expectations to pass . For more info see the
392
+ [DOM Testing Library docs ](https :// testing-library.com/docs/dom-testing-library/api-async#waitFor).
369
393
370
- This function will also call ` detectChanges ` repeatably to update the DOM , is helpful to test async functionality.
394
+ This function will also call `detectChanges` repeatably to update the DOM, which
395
+ is helpful to test async functionalities.
371
396
372
397
### `waitForElementToBeRemoved`
373
398
374
- Wait for the removal of element (s ) from the DOM.
375
- For more info see the [DOM Testing Library docs](https : // testing-library.com/docs/dom-testing-library/api-async#waitforelementtoberemoved).
399
+ Wait for the removal of element(s ) from the DOM. For more info see the
400
+ [DOM Testing Library docs](https : // testing-library.com/docs/dom-testing-library/api-async#waitforelementtoberemoved).
376
401
377
- This function will also call ` detectChanges ` repeatably to update the DOM , is helpful to test async functionality.
402
+ This function will also call ` detectChanges ` repeatably to update the DOM , which
403
+ is helpful to test async functionalities.
0 commit comments