Skip to content

Commit 1d0657b

Browse files
Angular testing library docs update (#1502)
1 parent 182ffff commit 1d0657b

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Documentation site for
99
[React Testing Library](https://github.com/testing-library/react-testing-library),
1010
[DOM Testing Library](https://github.com/testing-library/dom-testing-library),
11+
[Angular Testing Library](https://github.com/testing-library/angular-testing-library),
1112
and [related projects](https://github.com/testing-library)
1213

1314
**https://testing-library.com**

docs/angular-testing-library/api.mdx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ await render(AppComponent)
3838
Instead of passing the component's type as first argument, you can also provide
3939
a template. This practice is required to render directives but can also be
4040
applied to components, it might even be more useful. The directive's (or
41-
component's) type must then be added to the `declarations`.
41+
component's) type must then be added to the `imports` (or `declarations` in case
42+
of non-standalone components).
4243

4344
**example with directive**:
4445

@@ -103,12 +104,17 @@ the component.
103104
```ts
104105
// using a manual callback
105106
const sendValue = (value) => { ... }
107+
await render(AppComponent, {
108+
on: {
109+
send: (value) => sendValue(value),
110+
}
111+
})
112+
106113
// using a (jest) spy
107114
const sendValueSpy = jest.fn()
108115
109116
await render(AppComponent, {
110117
on: {
111-
send: (value) => sendValue(value),
112118
send: sendValueSpy
113119
}
114120
})
@@ -120,7 +126,7 @@ A collection of components, directives and pipes needed to render the component.
120126
For example, nested components of the component.
121127

122128
For more info see the
123-
[Angular docs](https://angular.io/api/core/NgModule#declarations).
129+
[Angular docs](https://angular.dev/guide/ngmodules/overview#declarations).
124130

125131
**default** : `[]`
126132

@@ -137,7 +143,7 @@ await render(AppComponent, {
137143
Set the defer blocks behavior.
138144

139145
For more info see the
140-
[Angular docs](https://angular.io/api/core/testing/DeferBlockBehavior)
146+
[Angular docs](https://angular.dev/api/core/testing/DeferBlockBehavior)
141147

142148
**default** : `undefined` (uses `DeferBlockBehavior.Manual`, which is different
143149
from the Angular default of `DeferBlockBehavior.Playthrough`)
@@ -155,7 +161,7 @@ await render(AppComponent, {
155161
Set the initial state of a deferrable blocks in a component.
156162

157163
For more info see the
158-
[Angular docs](https://angular.io/api/core/testing/DeferBlockState)
164+
[Angular docs](https://angular.dev/api/core/testing/DeferBlockState)
159165

160166
**default** : `undefined` (uses the Angular default, which is
161167
`DeferBlockState.Placeholder`)
@@ -177,7 +183,7 @@ These will be provided at the component level. To inject dependencies at the
177183
module level, use [`providers`](#providers).
178184

179185
For more info see the
180-
[Angular docs](https://angular.io/api/core/Directive#providers).
186+
[Angular docs](https://angular.dev/guide/di/hierarchical-dependency-injection#example-providing-services-in-component).
181187

182188
**default** : `[]`
183189

@@ -273,7 +279,7 @@ modules. Adds `NoopAnimationsModule` by default if `BrowserAnimationsModule`
273279
isn't added to the collection
274280

275281
For more info see the
276-
[Angular docs](https://angular.io/api/core/NgModule#imports).
282+
[Angular docs](https://angular.dev/guide/components#imports-in-the-component-decorator).
277283

278284
**default** : `[NoopAnimationsModule]`
279285

@@ -294,7 +300,7 @@ These will be provided at the module level. To inject dependencies at the
294300
component level, use [`componentProviders`](#componentProviders).
295301

296302
For more info see the
297-
[Angular docs](https://angular.io/api/core/NgModule#providers).
303+
[Angular docs](https://angular.dev/guide/di/dependency-injection-providers#).
298304

299305
**default** : `[]`
300306

@@ -331,7 +337,7 @@ await render(AppComponent, {
331337

332338
The route configuration to set up the router service via
333339
`RouterTestingModule.withRoutes`. For more info see the
334-
[Angular Routes docs](https://angular.io/api/router/Routes).
340+
[Angular Routes docs](https://angular.dev/api/router/Routes).
335341

336342
**default** : `[]`
337343

@@ -360,7 +366,7 @@ A collection of schemas needed to render the component. Allowed values are
360366
`NO_ERRORS_SCHEMA` and `CUSTOM_ELEMENTS_SCHEMA`.
361367

362368
For more info see the
363-
[Angular docs](https://angular.io/api/core/NgModule#schemas).
369+
[Angular docs](https://angular.dev/guide/components/advanced-configuration#custom-element-schemas).
364370

365371
**default** : `[]`
366372

@@ -511,20 +517,20 @@ expect(screen.getByTestId('name-value').textContent).toBe('Sarah')
511517
Trigger a change detection cycle for the component.
512518

513519
For more info see the
514-
[Angular docs](https://angular.io/api/core/testing/ComponentFixture#detectChanges).
520+
[Angular docs](https://angular.dev/api/core/testing/ComponentFixture#detectChanges).
515521

516522
### `debugElement`
517523

518524
The Angular `DebugElement` of the component.
519525

520-
For more info see the [Angular docs](https://angular.io/api/core/DebugElement).
526+
For more info see the [Angular docs](https://angular.dev/api/core/DebugElement).
521527

522528
### `fixture`
523529

524530
The Angular `ComponentFixture` of the component.
525531

526532
For more info see the
527-
[Angular docs](https://angular.io/api/core/testing/ComponentFixture).
533+
[Angular docs](https://angular.dev/api/core/testing/ComponentFixture).
528534

529535
```typescript
530536
const {fixture} = await render(AppComponent)

0 commit comments

Comments
 (0)