docs(core): Document TestBed.get deprecation (#32974)
It was replaced by TestBed.inject, documenting such change. PR Close #32974
This commit is contained in:
parent
9de4b1c441
commit
717bace7ba
@ -29,6 +29,7 @@ v5 - v8
|
|||||||
v6 - v9
|
v6 - v9
|
||||||
v7 - v10
|
v7 - v10
|
||||||
v8 - v11
|
v8 - v11
|
||||||
|
v9 - v12
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ v8 - v11
|
|||||||
| `@angular/core` | [`defineInjectable`](#core) | v11 |
|
| `@angular/core` | [`defineInjectable`](#core) | v11 |
|
||||||
| `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 |
|
| `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 |
|
||||||
| `@angular/router` | [`ActivatedRoute` params and `queryParams` properties](#activatedroute-props) | unspecified |
|
| `@angular/router` | [`ActivatedRoute` params and `queryParams` properties](#activatedroute-props) | unspecified |
|
||||||
|
| `@angular/core/testing` | [`TestBed.get`](#testing) | v12 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +88,14 @@ Tip: In the [API reference section](api) of this doc site, deprecated APIs are i
|
|||||||
| [`ANALYZE_FOR_ENTRY_COMPONENTS`](api/core/ANALYZE_FOR_ENTRY_COMPONENTS) | none | v9 | See [`ANALYZE_FOR_ENTRY_COMPONENTS`](#entryComponents) |
|
| [`ANALYZE_FOR_ENTRY_COMPONENTS`](api/core/ANALYZE_FOR_ENTRY_COMPONENTS) | none | v9 | See [`ANALYZE_FOR_ENTRY_COMPONENTS`](#entryComponents) |
|
||||||
|
|
||||||
|
|
||||||
|
{@a testing}
|
||||||
|
### @angular/core/testing
|
||||||
|
|
||||||
|
| API | Replacement | Deprecation announced | Notes |
|
||||||
|
| --- | ----------- | --------------------- | ----- |
|
||||||
|
| [`TestBed.get`](api/core/testing/TestBed#get) | [`TestBed.inject`](api/core/testing/TestBed#inject) | v9 | Same behavior, but type safe. |
|
||||||
|
|
||||||
|
|
||||||
{@a forms}
|
{@a forms}
|
||||||
### @angular/forms
|
### @angular/forms
|
||||||
|
|
||||||
|
@ -357,11 +357,15 @@ array of the services that you'll test or mock.
|
|||||||
|
|
||||||
Then inject it inside a test by calling `TestBed.inject()` with the service class as the argument.
|
Then inject it inside a test by calling `TestBed.inject()` with the service class as the argument.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
**Note:** We used to have `TestBed.get()` instead of `TestBed.inject()`.
|
**Note:** We used to have `TestBed.get()` instead of `TestBed.inject()`.
|
||||||
The `get` method wasn't type safe, it always returned `any`, and this is error prone.
|
The `get` method wasn't type safe, it always returned `any`, and this is error prone.
|
||||||
We decided to migrate to a new function instead of updating the existing one given
|
We decided to migrate to a new function instead of updating the existing one given
|
||||||
the large scale use that would have an immense amount of breaking changes.
|
the large scale use that would have an immense amount of breaking changes.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<code-example
|
<code-example
|
||||||
path="testing/src/app/demo/demo.testbed.spec.ts"
|
path="testing/src/app/demo/demo.testbed.spec.ts"
|
||||||
region="value-service-inject-it">
|
region="value-service-inject-it">
|
||||||
@ -1065,7 +1069,7 @@ The component injector is a property of the fixture's `DebugElement`.
|
|||||||
header="WelcomeComponent's injector">
|
header="WelcomeComponent's injector">
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
{@a testbed-get}
|
{@a testbed-inject}
|
||||||
|
|
||||||
#### _TestBed.inject()_
|
#### _TestBed.inject()_
|
||||||
|
|
||||||
@ -3079,8 +3083,8 @@ Here are the most important static methods, in order of likely utility.
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: top">
|
<td style="vertical-align: top">
|
||||||
{@a testbed-get}
|
{@a testbed-inject}
|
||||||
<code>get</code>
|
<code>inject</code>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user