From 717bace7ba5a01df8c18aeea02d6c4f2aaf6da82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ortiz=20Garc=C3=ADa?= Date: Wed, 2 Oct 2019 14:30:18 -0700 Subject: [PATCH] docs(core): Document TestBed.get deprecation (#32974) It was replaced by TestBed.inject, documenting such change. PR Close #32974 --- aio/content/guide/deprecations.md | 10 ++++++++++ aio/content/guide/testing.md | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/aio/content/guide/deprecations.md b/aio/content/guide/deprecations.md index c6fc6547d8..19d092ce51 100644 --- a/aio/content/guide/deprecations.md +++ b/aio/content/guide/deprecations.md @@ -29,6 +29,7 @@ v5 - v8 v6 - v9 v7 - v10 v8 - v11 +v9 - v12 --> @@ -51,6 +52,7 @@ v8 - v11 | `@angular/core` | [`defineInjectable`](#core) | v11 | | `@angular/router` | [`loadChildren` string syntax](#loadChildren) | v11 | | `@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) | +{@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} ### @angular/forms diff --git a/aio/content/guide/testing.md b/aio/content/guide/testing.md index 6ee6846330..40075f6edb 100644 --- a/aio/content/guide/testing.md +++ b/aio/content/guide/testing.md @@ -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. +
+ **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. 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. +
+ @@ -1065,7 +1069,7 @@ The component injector is a property of the fixture's `DebugElement`. header="WelcomeComponent's injector"> -{@a testbed-get} +{@a testbed-inject} #### _TestBed.inject()_ @@ -3079,8 +3083,8 @@ Here are the most important static methods, in order of likely utility. - {@a testbed-get} - get + {@a testbed-inject} + inject