`を表す`DebugElement`です。
-It has Angular properties and methods that abstract interaction with the native element.
-This test calls the `DebugElement.triggerEventHandler` with the "click" event name.
-The "click" event binding responds by calling `DashboardHeroComponent.click()`.
+これは、ネイティブ要素との対話を抽象化するAngularのプロパティとメソッドを持っています。
+このテストは、"click"イベント名で`DebugElement.triggerEventHandler`を呼び出します。
+"click"イベントバインディングは、`DashboardHeroComponent.click()`を呼び出すことで応答します。
-The Angular `DebugElement.triggerEventHandler` can raise *any data-bound event* by its *event name*.
-The second parameter is the event object passed to the handler.
+Angularの`DebugElement.triggerEventHandler`は、*イベント名*を使用して、*データバインドされたイベント*を発生させることができます。
+2番目のパラメーターは、ハンドラーに渡されるイベントオブジェクトです。
-The test triggered a "click" event.
+テストでは、"click"イベントをトリガーしました。
-In this case, the test correctly assumes that the runtime event handler, the component's `click()` method, doesn't care about the event object.
+この場合、テストでは、ランタイムイベントハンドラーであるコンポーネントの`click()`メソッドがイベントオブジェクトを気にしないことを正しく想定しています。
-HELPFUL: Other handlers are less forgiving.
-For example, the `RouterLink` directive expects an object with a `button` property that identifies which mouse button, if any, was pressed during the click.
-The `RouterLink` directive throws an error if the event object is missing.
+HELPFUL: 他のハンドラーは、それほど寛容ではありません。
+たとえば、`RouterLink`ディレクティブは、クリック時にどのマウスボタンが押されたかを識別する`button`プロパティを持つオブジェクトを期待しています。
+`RouterLink`ディレクティブは、イベントオブジェクトが不足している場合、エラーをスローします。
-### Click the element
+### 要素をクリックする
-The following test alternative calls the native element's own `click()` method, which is perfectly fine for *this component*.
+次のテストの代替案は、ネイティブ要素自身の`click()`メソッドを呼び出します。これは、*このコンポーネント*には完全に適しています。
-### `click()` helper
+### `click()`ヘルパー
-Clicking a button, an anchor, or an arbitrary HTML element is a common test task.
+ボタン、アンカー、または任意のHTML要素をクリックすることは、一般的なテストタスクです。
-Make that consistent and straightforward by encapsulating the *click-triggering* process in a helper such as the following `click()` function:
+次の`click()`関数のようなヘルパーに*クリックをトリガーする*プロセスをカプセル化することで、それを一貫性があり、簡単に行うことができます。
-The first parameter is the *element-to-click*.
-If you want, pass a custom event object as the second parameter.
-The default is a partial [left-button mouse event object](https://developer.mozilla.org/docs/Web/API/MouseEvent/button) accepted by many handlers including the `RouterLink` directive.
+最初の引数は、*クリックする要素*です。
+必要に応じて、2番目の引数としてカスタムイベントオブジェクトを渡すことができます。
+デフォルトは、`RouterLink`ディレクティブを含む多くのハンドラーで受け入れられる、部分的な[左ボタンのマウスイベントオブジェクト](https://developer.mozilla.org/docs/Web/API/MouseEvent/button)です。
-IMPORTANT: The `click()` helper function is **not** one of the Angular testing utilities.
-It's a function defined in *this guide's sample code*.
-All of the sample tests use it.
-If you like it, add it to your own collection of helpers.
+IMPORTANT: `click()`ヘルパー関数は、Angularのテストユーティリティの**1つではありません**。
+これは、*このガイドのサンプルコード*で定義された関数です。
+サンプルテストはすべてこれを利用しています。
+気に入ったら、自分のヘルパーのコレクションに追加してください。
-Here's the previous test, rewritten using the click helper.
+次に、クリックヘルパーを使用した前のテストを示します。
-
-## Component inside a test host
+
+## テストホスト内のコンポーネント
-The previous tests played the role of the host `DashboardComponent` themselves.
-But does the `DashboardHeroComponent` work correctly when properly data-bound to a host component?
+前のテストは、ホスト`DashboardComponent`の役割を自身で演じていました。
+しかし、`DashboardHeroComponent`は、ホストコンポーネントに適切にデータバインドされている場合、正しく動作するでしょうか?
-You could test with the actual `DashboardComponent`.
-But doing so could require a lot of setup, especially when its template features an `*ngFor` repeater, other components, layout HTML, additional bindings, a constructor that injects multiple services, and it starts interacting with those services right away.
+実際の`DashboardComponent`でテストすることもできます。
+しかし、そうすると、特にテンプレートに`*ngFor`リピーター、他のコンポーネント、レイアウトHTML、追加のバインディング、複数のサービスを注入するコンストラクター、そしてそのサービスとすぐにやり取りを開始するコンストラクターが含まれている場合、多くのセットアップが必要になる可能性があります。
-Imagine the effort to disable these distractions, just to prove a point that can be made satisfactorily with a *test host* like this one:
+このような邪魔なものをすべて無効にする労力を想像してみてください。それは、単に次のような*テストホスト*で十分に説明できるポイントを証明するためだけです。
-This test host binds to `DashboardHeroComponent` as the `DashboardComponent` would but without the noise of the `Router`, the `HeroService`, or the `*ngFor` repeater.
+このテストホストは、`DashboardComponent`が行うように`DashboardHeroComponent`にバインドしますが、`Router`、`HeroService`、または`*ngFor`リピーターのノイズはありません。
-The test host sets the component's `hero` input property with its test hero.
-It binds the component's `selected` event with its `onSelected` handler, which records the emitted hero in its `selectedHero` property.
+テストホストは、コンポーネントの`hero`入力プロパティをテストヒーローで設定します。
+これは、コンポーネントの`selected`イベントを`onSelected`ハンドラーにバインドし、これは`selectedHero`プロパティに発行されたヒーローを記録します。
-Later, the tests will be able to check `selectedHero` to verify that the `DashboardHeroComponent.selected` event emitted the expected hero.
+後で、テストは`selectedHero`をチェックして、`DashboardHeroComponent.selected`イベントが期待どおりのヒーローを発行したことを確認できます。
-The setup for the `test-host` tests is similar to the setup for the stand-alone tests:
+`test-host`テストの設定は、スタンドアロンテストの設定に似ています。
-This testing module configuration shows three important differences:
+このテストモジュール設定は、3つの重要な違いを示しています。
-* It *declares* both the `DashboardHeroComponent` and the `TestHostComponent`
-* It *creates* the `TestHostComponent` instead of the `DashboardHeroComponent`
-* The `TestHostComponent` sets the `DashboardHeroComponent.hero` with a binding
+* `DashboardHeroComponent`と`TestHostComponent`の両方を*宣言*します
+* `DashboardHeroComponent`ではなく`TestHostComponent`を*作成*します
+* `TestHostComponent`は、バインディングで`DashboardHeroComponent.hero`を設定します
-The `createComponent` returns a `fixture` that holds an instance of `TestHostComponent` instead of an instance of `DashboardHeroComponent`.
+`createComponent`は、`DashboardHeroComponent`のインスタンスではなく、`TestHostComponent`のインスタンスを保持する`fixture`を返します。
-Creating the `TestHostComponent` has the side effect of creating a `DashboardHeroComponent` because the latter appears within the template of the former.
-The query for the hero element \(`heroEl`\) still finds it in the test DOM, albeit at greater depth in the element tree than before.
+`TestHostComponent`を作成すると、後者が前者のテンプレート内に表示されているため、`DashboardHeroComponent`が作成されます。
+ヒーロー要素(`heroEl`)のクエリは、テストDOM内で見つかりますが、前のテストよりも要素ツリーの深さが大きくなります。
-The tests themselves are almost identical to the stand-alone version:
+テスト自体は、スタンドアロンバージョンとほとんど同じです。
-Only the selected event test differs.
-It confirms that the selected `DashboardHeroComponent` hero really does find its way up through the event binding to the host component.
+選択されたイベントテストのみが異なります。
+これは、選択された`DashboardHeroComponent`のヒーローが、実際にイベントバインディングを通じてホストコンポーネントに到達することを確認します。
-## Routing component
+## ルーティングコンポーネント
-A *routing component* is a component that tells the `Router` to navigate to another component.
-The `DashboardComponent` is a *routing component* because the user can navigate to the `HeroDetailComponent` by clicking on one of the *hero buttons* on the dashboard.
+*ルーティングコンポーネント*は、`Router`に別のコンポーネントにナビゲートするように指示するコンポーネントです。
+`DashboardComponent`は、ユーザーがダッシュボードの*ヒーローボタン*の1つをクリックすることで`HeroDetailComponent`にナビゲートできるため、*ルーティングコンポーネント*です。
-Routing is pretty complicated.
-Testing the `DashboardComponent` seemed daunting in part because it involves the `Router`, which it injects together with the `HeroService`.
+ルーティングは非常に複雑です。
+`DashboardComponent`をテストするのは、`Router`を注入し、`HeroService`と組み合わせて注入するため、困難でした。
-Angular provides test helpers to reduce boilerplate and more effectively test code which depends on the Router and HttpClient.
+Angularは、ルーターとHttpClientに依存するコードをより効果的にテストするために、テストヘルパーを提供しています。
-The following test clicks the displayed hero and confirms that we navigate to the expected URL.
+次のテストは、表示されているヒーローをクリックし、期待されるURLにナビゲートしたことを確認します。
-## Routed components
+## ルーティングされたコンポーネント
-A *routed component* is the destination of a `Router` navigation.
-It can be trickier to test, especially when the route to the component *includes parameters*.
-The `HeroDetailComponent` is a *routed component* that is the destination of such a route.
+*ルーティングされたコンポーネント*は、`Router`ナビゲーションの宛先です。
+特に、コンポーネントへのルートに*パラメーターが含まれている場合*、テストが難しくなる場合があります。
+`HeroDetailComponent`は、このようなルートの宛先である*ルーティングされたコンポーネント*です。
-When a user clicks a *Dashboard* hero, the `DashboardComponent` tells the `Router` to navigate to `heroes/:id`.
-The `:id` is a route parameter whose value is the `id` of the hero to edit.
+ユーザーが*Dashboard*のヒーローをクリックすると、`DashboardComponent`は`Router`に`heroes/:id`にナビゲートするように指示します。
+`:id`は、編集するヒーローの`id`であるルートパラメーターです。
-The `Router` matches that URL to a route to the `HeroDetailComponent`.
-It creates an `ActivatedRoute` object with the routing information and injects it into a new instance of the `HeroDetailComponent`.
+`Router`は、そのURLを`HeroDetailComponent`へのルートと照合します。
+これは、ルーティング情報を持つ`ActivatedRoute`オブジェクトを作成し、`HeroDetailComponent`の新しいインスタンスに注入します。
-Here's the `HeroDetailComponent` constructor:
+`HeroDetailComponent`のコンストラクターを次に示します。
-The `HeroDetail` component needs the `id` parameter so it can fetch the corresponding hero using the `HeroDetailService`.
-The component has to get the `id` from the `ActivatedRoute.paramMap` property which is an `Observable`.
+`HeroDetail`コンポーネントは、`id`パラメーターが必要であり、これにより`HeroDetailService`を使用して対応するヒーローを取得できます。
+コンポーネントは、`Observable`である`ActivatedRoute.paramMap`プロパティから`id`を取得する必要があります。
-It can't just reference the `id` property of the `ActivatedRoute.paramMap`.
-The component has to *subscribe* to the `ActivatedRoute.paramMap` observable and be prepared for the `id` to change during its lifetime.
+コンポーネントは、`ActivatedRoute.paramMap`の`id`プロパティを参照することはできません。
+コンポーネントは、`ActivatedRoute.paramMap`Observableを*購読*し、ライフタイム中に`id`が変更される場合に備えておく必要があります。
-Tests can explore how the `HeroDetailComponent` responds to different `id` parameter values by navigating to different routes.
+テストでは、異なるルートにナビゲートすることで、`HeroDetailComponent`が異なる`id`パラメーター値にどのように応答するかを調べることができます。
-### Testing with the `RouterTestingHarness`
+### `RouterTestingHarness`によるテスト
-Here's a test demonstrating the component's behavior when the observed `id` refers to an existing hero:
+次に、観察された`id`が既存のヒーローを参照している場合に、コンポーネントの動作を示すテストを示します。
-HELPFUL: In the following section, the `createComponent()` method and `page` object are discussed.
-Rely on your intuition for now.
+HELPFUL: 後のセクションでは、`createComponent()`メソッドと`page`オブジェクトについて説明します。
+今のところ、直感的に理解してください。
-When the `id` cannot be found, the component should re-route to the `HeroListComponent`.
+`id`が見つからない場合、コンポーネントは`HeroListComponent`にリダイレクトする必要があります。
-The test suite setup provided the same router harness [described above](#routing-component).
+テストスイートの設定では、同じルーターハーネスが提供されました[上記を参照](#routing-component)。
-This test expects the component to try to navigate to the `HeroListComponent`.
+このテストは、コンポーネントが`HeroListComponent`へのナビゲーションを試みると予想しています。
-## Nested component tests
+## ネストされたコンポーネントテスト
-Component templates often have nested components, whose templates might contain more components.
+コンポーネントテンプレートには、多くの場合、ネストされたコンポーネントが含まれています。そのテンプレートには、さらに多くのコンポーネントが含まれている場合があります。
-The component tree can be very deep and, most of the time, the nested components play no role in testing the component at the top of the tree.
+コンポーネントツリーは非常に深くなる可能性があり、ほとんどの場合、ネストされたコンポーネントはツリーの先頭に配置されたコンポーネントをテストする際に役割を果たしません。
-The `AppComponent`, for example, displays a navigation bar with anchors and their `RouterLink` directives.
+たとえば、`AppComponent`は、アンカーと`RouterLink`ディレクティブを持つナビゲーションバーを表示します。
-To validate the links, you don't need the `Router` to navigate and you don't need the `
` to mark where the `Router` inserts *routed components*.
+リンクを検証するために、`Router`がナビゲートする必要はなく、`Router`が*ルーティングされたコンポーネント*を挿入する場所を示す``も必要ありません。
-The `BannerComponent` and `WelcomeComponent` \(indicated by `` and ``\) are also irrelevant.
+`BannerComponent`と`WelcomeComponent`(``と``で示されています)も関係ありません。
-Yet any test that creates the `AppComponent` in the DOM also creates instances of these three components and, if you let that happen, you'll have to configure the `TestBed` to create them.
+しかし、DOMに`AppComponent`を作成するテストは、これらの3つのコンポーネントのインスタンスも作成し、それを許可した場合、`TestBed`を設定してそれらを作成する必要があります。
-If you neglect to declare them, the Angular compiler won't recognize the ``, ``, and `` tags in the `AppComponent` template and will throw an error.
+それらを宣言することを怠ると、Angularコンパイラーは`AppComponent`テンプレートの``、``、および``タグを認識せず、エラーをスローします。
-If you declare the real components, you'll also have to declare *their* nested components and provide for *all* services injected in *any* component in the tree.
+実際のコンポーネントを宣言すると、*それら*のネストされたコンポーネントも宣言し、ツリー内の*任意の*コンポーネントに注入された*すべての*サービスを提供する必要があります。
-That's too much effort just to answer a few simple questions about links.
+それは、リンクに関する簡単な質問に答えるために、あまりにも多くの労力が必要です。
-This section describes two techniques for minimizing the setup.
-Use them, alone or in combination, to stay focused on testing the primary component.
+このセクションでは、セットアップを最小限にするための2つのテクニックについて説明します。
+これらを単独で、または組み合わせて使用して、主要なコンポーネントのテストに集中してください。
-### Stubbing unneeded components
+### 不要なコンポーネントのスタブ化
-In the first technique, you create and declare stub versions of the components and directive that play little or no role in the tests.
+最初のテクニックでは、テストでほとんど役割を果たさないコンポーネントとディレクティブのスタブバージョンを作成して宣言します。
-The stub selectors match the selectors for the corresponding real components.
-But their templates and classes are empty.
+スタブセレクターは、対応する実際のコンポーネントのセレクターと一致します。
+しかし、それらのテンプレートとクラスは空です。
-Then declare them in the `TestBed` configuration next to the components, directives, and pipes that need to be real.
+次に、`TestBed`設定内で、実際にする必要があるコンポーネント、ディレクティブ、パイプの横に宣言します。
-The `AppComponent` is the test subject, so of course you declare the real version.
+`AppComponent`はテスト対象なので、当然、実際のバージョンを宣言します。
-The rest are stubs.
+残りはスタブです。
### `NO_ERRORS_SCHEMA`
-In the second approach, add `NO_ERRORS_SCHEMA` to the `TestBed.schemas` metadata.
+2番目の方法では、`TestBed.schemas`メタデータに`NO_ERRORS_SCHEMA`を追加します。
-The `NO_ERRORS_SCHEMA` tells the Angular compiler to ignore unrecognized elements and attributes.
+`NO_ERRORS_SCHEMA`は、Angularコンパイラーに、認識されていない要素と属性を無視するように指示します。
-The compiler recognizes the `` element and the `routerLink` attribute because you declared a corresponding `AppComponent` and `RouterLink` in the `TestBed` configuration.
+コンパイラーは、`TestBed`設定で対応する`AppComponent`と`RouterLink`を宣言したため、``要素と`routerLink`属性を認識します。
-But the compiler won't throw an error when it encounters ``, ``, or ``.
-It simply renders them as empty tags and the browser ignores them.
+しかし、コンパイラーは``、``、または``に遭遇してもエラーをスローしません。
+単にそれらを空のタグとしてレンダリングし、ブラウザはそれらを無視します。
-You no longer need the stub components.
+スタブコンポーネントは不要になりました。
-### Use both techniques together
+### 2つのテクニックを組み合わせて使用する
-These are techniques for *Shallow Component Testing*, so-named because they reduce the visual surface of the component to just those elements in the component's template that matter for tests.
+これらは、*シャローコンポーネントテスト*のためのテクニックであり、コンポーネントの視覚的な表面を、テストにとって重要なコンポーネントのテンプレート内の要素だけに制限するため、そう呼ばれています。
-The `NO_ERRORS_SCHEMA` approach is the easier of the two but don't overuse it.
+`NO_ERRORS_SCHEMA`アプローチは2つのうちより簡単ですが、使い過ぎないでください。
-The `NO_ERRORS_SCHEMA` also prevents the compiler from telling you about the missing components and attributes that you omitted inadvertently or misspelled.
-You could waste hours chasing phantom bugs that the compiler would have caught in an instant.
+`NO_ERRORS_SCHEMA`は、コンパイラーが意図的に省略した、または誤ってスペルミスをした、見逃したコンポーネントと属性について警告するのを防ぎます。
+コンパイラーが瞬時に検出できたはずの幽霊バグを追いかけて何時間も無駄にする可能性があります。
-The *stub component* approach has another advantage.
-While the stubs in *this* example were empty, you could give them stripped-down templates and classes if your tests need to interact with them in some way.
+*スタブコンポーネント*アプローチには、もう1つの利点があります。
+*この*例ではスタブは空でしたが、テストでそれらと何らかの形で対話する必要がある場合は、縮小されたテンプレートとクラスを与えることができます。
-In practice you will combine the two techniques in the same setup, as seen in this example.
+実際には、次の例のように、2つのテクニックを同じセットアップに組み合わせます。
-The Angular compiler creates the `BannerStubComponent` for the `` element and applies the `RouterLink` to the anchors with the `routerLink` attribute, but it ignores the `` and `` tags.
+Angularコンパイラーは、``要素に対して`BannerStubComponent`を作成し、`routerLink`属性を持つアンカーに`RouterLink`を適用しますが、``と``タグは無視します。
-### `By.directive` and injected directives
+### `By.directive`と注入されたディレクティブ
-A little more setup triggers the initial data binding and gets references to the navigation links:
+さらに少しセットアップすると、初期データバインディングがトリガーされ、ナビゲーションリンクへの参照が取得されます。
-Three points of special interest:
+3つの重要なポイントを次に示します。
-* Locate the anchor elements with an attached directive using `By.directive`
-* The query returns `DebugElement` wrappers around the matching elements
-* Each `DebugElement` exposes a dependency injector with the specific instance of the directive attached to that element
+* `By.directive`を使用して、アタッチされたディレクティブを持つアンカー要素を見つけます
+* クエリは、一致する要素をラップする`DebugElement`ラッパーを返します
+* 各`DebugElement`は、その要素にアタッチされたディレクティブの特定のインスタンスを含む依存関係インジェクターを公開します
-The `AppComponent` links to validate are as follows:
+`AppComponent`が検証するリンクは次のとおりです。
-Here are some tests that confirm those links are wired to the `routerLink` directives as expected:
+次に、これらのリンクが期待どおりに`routerLink`ディレクティブに配線されていることを確認するテストを示します。
-## Use a `page` object
+## `page`オブジェクトの使用
-The `HeroDetailComponent` is a simple view with a title, two hero fields, and two buttons.
+`HeroDetailComponent`は、タイトル、2つのヒーローフィールド、2つのボタンを持つ単純なビューです。
-But there's plenty of template complexity even in this simple form.
+しかし、この単純な形式でも、テンプレートの複雑さはたくさんあります。
-Tests that exercise the component need …
+コンポーネントをテストするものは、…
-* To wait until a hero arrives before elements appear in the DOM
-* A reference to the title text
-* A reference to the name input box to inspect and set it
-* References to the two buttons so they can click them
-* Spies for some of the component and router methods
+* ヒーローが到着するまで待つ必要がある
+* タイトルテキストへの参照
+* 検査および設定するための名前入力ボックスへの参照
+* クリックできる2つのボタンへの参照
+* コンポーネントとルーターのメソッドのスパイ
-Even a small form such as this one can produce a mess of tortured conditional setup and CSS element selection.
+このような小さなフォームでも、むち打ちの条件付きセットアップとCSS要素の選択の混乱を招く可能性があります。
-Tame the complexity with a `Page` class that handles access to component properties and encapsulates the logic that sets them.
+コンポーネントのプロパティへのアクセスを処理し、それらを設定するロジックをカプセル化する`Page`クラスを使用して、複雑さを抑制します。
-Here is such a `Page` class for the `hero-detail.component.spec.ts`
+次に、`hero-detail.component.spec.ts`の`Page`クラスを示します。
-Now the important hooks for component manipulation and inspection are neatly organized and accessible from an instance of `Page`.
+これで、コンポーネントの操作と検査のための重要なフックが、整理され、`Page`のインスタンスからアクセスできるようになりました。
-A `createComponent` method creates a `page` object and fills in the blanks once the `hero` arrives.
+`createComponent`メソッドは、`page`オブジェクトを作成し、`hero`が到着すると空白を埋めます。
-Here are a few more `HeroDetailComponent` tests to reinforce the point.
+次に、ポイントを強化するための`HeroDetailComponent`のテストをいくつか示します。
-## Calling `compileComponents()`
+## `compileComponents()`の呼び出し
-HELPFUL: Ignore this section if you *only* run tests with the CLI `ng test` command because the CLI compiles the application before running the tests.
+HELPFUL: CLI`ng test`コマンドでのみテストを実行している場合は、このセクションを無視してください。なぜなら、CLIはテストを実行する前にアプリケーションをコンパイルするからです。
-If you run tests in a **non-CLI environment**, the tests might fail with a message like this one:
+**CLI以外の環境**でテストを実行する場合、テストは次のようなメッセージで失敗する可能性があります。
@@ -766,29 +766,29 @@ Please call "TestBed.compileComponents" before your test.
-The root of the problem is at least one of the components involved in the test specifies an external template or CSS file as the following version of the `BannerComponent` does.
+問題の根本は、テストに関与するコンポーネントの少なくとも1つが、`BannerComponent`の次のバージョンで行われているように、外部テンプレートまたはCSSファイルを指定していることです。
-The test fails when the `TestBed` tries to create the component.
+テストは、`TestBed`がコンポーネントの作成を試みたときに失敗します。
-Recall that the application hasn't been compiled.
-So when you call `createComponent()`, the `TestBed` compiles implicitly.
+アプリケーションはコンパイルされていないことを思い出してください。
+そのため、`createComponent()`を呼び出すと、`TestBed`は暗黙的にコンパイルします。
-That's not a problem when the source code is in memory.
-But the `BannerComponent` requires external files that the compiler must read from the file system, an inherently *asynchronous* operation.
+これは、ソースコードがメモリ内にある場合は問題ありません。
+しかし、`BannerComponent`は外部ファイルが必要であり、コンパイラーはファイルシステムからそれらを読み取る必要があります。これは本質的に*非同期*操作です。
-If the `TestBed` were allowed to continue, the tests would run and fail mysteriously before the compiler could finish.
+`TestBed`が続行することを許可すると、テストが実行され、コンパイラーが完了する前に、不可解な理由で失敗します。
-The preemptive error message tells you to compile explicitly with `compileComponents()`.
+予防的なエラーメッセージは、`compileComponents()`で明示的にコンパイルするように指示しています。
-### `compileComponents()` is async
+### `compileComponents()`は非同期です
-You must call `compileComponents()` within an asynchronous test function.
+`compileComponents()`は、非同期テスト関数内で呼び出す必要があります。
-CRITICAL: If you neglect to make the test function async (for example, forget to use `waitForAsync()` as described), you'll see this error message
+CRITICAL: テスト関数を非同期にするのを怠ると(たとえば、[waitForAsync()](#waitForAsync)の使用を忘れると)、次のようなエラーメッセージが表示されます。
@@ -796,156 +796,156 @@ Error: ViewDestroyedError: Attempt to use a destroyed view
-A typical approach is to divide the setup logic into two separate `beforeEach()` functions:
+一般的なアプローチは、セットアップロジックを2つの別の`beforeEach()`関数に分割することです。
-| Functions | Details |
-| :-------------------------- | :--------------------------- |
-| Asynchronous `beforeEach()` | Compiles the components |
-| Synchronous `beforeEach()` | Performs the remaining setup |
+| 関数 | 詳細 |
+| :----------------------- | :---------------------------- |
+| 非同期`beforeEach()` | コンポーネントをコンパイルする |
+| 同期`beforeEach()` | 残りのセットアップを実行する |
-### The async `beforeEach`
+### 非同期`beforeEach`
-Write the first async `beforeEach` like this.
+最初の非同期`beforeEach`は、次のように記述します。
-The `TestBed.configureTestingModule()` method returns the `TestBed` class so you can chain calls to other `TestBed` static methods such as `compileComponents()`.
+`TestBed.configureTestingModule()`メソッドは、`TestBed`クラスを返し、`compileComponents()`などの他の`TestBed`の静的メソッドへの呼び出しをチェーンすることができます。
-In this example, the `BannerComponent` is the only component to compile.
-Other examples configure the testing module with multiple components and might import application modules that hold yet more components.
-Any of them could require external files.
+この例では、`BannerComponent`はコンパイルする必要がある唯一のコンポーネントです。
+他の例では、複数のコンポーネントでテストモジュールを設定し、さらに多くのコンポーネントを保持するアプリケーションモジュールをインポートする場合があります。
+それらのいずれかが外部ファイルが必要になる可能性があります。
-The `TestBed.compileComponents` method asynchronously compiles all components configured in the testing module.
+`TestBed.compileComponents`メソッドは、テストモジュールで設定されたすべてのコンポーネントを非同期的にコンパイルします。
-IMPORTANT: Do not re-configure the `TestBed` after calling `compileComponents()`.
+IMPORTANT: `compileComponents()`を呼び出した後、`TestBed`を再設定しないでください。
-Calling `compileComponents()` closes the current `TestBed` instance to further configuration.
-You cannot call any more `TestBed` configuration methods, not `configureTestingModule()` nor any of the `override...` methods.
-The `TestBed` throws an error if you try.
+`compileComponents()`を呼び出すと、現在の`TestBed`インスタンスがさらに設定されなくなります。
+`configureTestingModule()`や`override...`メソッドなど、`TestBed`の構成メソッドをさらに呼び出すことはできません。
+`TestBed`は、試行するとエラーをスローします。
-Make `compileComponents()` the last step before calling `TestBed.createComponent()`.
+`compileComponents()`を、`TestBed.createComponent()`を呼び出す前の最後のステップにしてください。
-### The synchronous `beforeEach`
+### 同期`beforeEach`
-The second, synchronous `beforeEach()` contains the remaining setup steps, which include creating the component and querying for elements to inspect.
+2番目の、同期`beforeEach()`には、残りのセットアップ手順が含まれます。これには、コンポーネントの作成と、検査する要素のクエリが含まれます。
-Count on the test runner to wait for the first asynchronous `beforeEach` to finish before calling the second.
+テストランナーは、最初の非同期`beforeEach`が終了するまで待ってから、2番目を呼び出します。
-### Consolidated setup
+### 統合された設定
-You can consolidate the two `beforeEach()` functions into a single, async `beforeEach()`.
+2つの`beforeEach()`関数を、1つの非同期`beforeEach()`に統合できます。
-The `compileComponents()` method returns a promise so you can perform the synchronous setup tasks *after* compilation by moving the synchronous code after the `await` keyword, where the promise has been resolved.
+`compileComponents()`メソッドはプロミスを返すため、同期セットアップタスクを*コンパイル後*に実行することができます。そのため、同期コードを`await`キーワードの後に移動します。この時点で、プロミスは解決されています。
-### `compileComponents()` is harmless
+### `compileComponents()`は安全です
-There's no harm in calling `compileComponents()` when it's not required.
+`compileComponents()`を呼び出しても、必要ない場合でも害はありません。
-The component test file generated by the CLI calls `compileComponents()` even though it is never required when running `ng test`.
+CLIによって生成されたコンポーネントテストファイルは、`ng test`を実行しているときは不要ですが、`compileComponents()`を呼び出します。
-The tests in this guide only call `compileComponents` when necessary.
+このガイドのテストでは、必要に応じてのみ`compileComponents`を呼び出します。
-## Setup with module imports
+## モジュールインポートによるセットアップ
-Earlier component tests configured the testing module with a few `declarations` like this:
+以前のコンポーネントテストでは、次のようにテストモジュールをいくつかの`declarations`で設定していました。
-The `DashboardComponent` is simple.
-It needs no help.
-But more complex components often depend on other components, directives, pipes, and providers and these must be added to the testing module too.
+`DashboardComponent`はシンプルです。
+助けは必要ありません。
+しかし、より複雑なコンポーネントは、多くの場合、他のコンポーネント、ディレクティブ、パイプ、およびプロバイダーに依存しており、これらをテストモジュールにも追加する必要があります。
-Fortunately, the `TestBed.configureTestingModule` parameter parallels the metadata passed to the `@NgModule` decorator which means you can also specify `providers` and `imports`.
+幸いなことに、`TestBed.configureTestingModule`のパラメーターは、`@NgModule`デコレーターに渡されるメタデータと並行しているため、`providers`と`imports`も指定できます。
-The `HeroDetailComponent` requires a lot of help despite its small size and simple construction.
-In addition to the support it receives from the default testing module `CommonModule`, it needs:
+`HeroDetailComponent`は、小さいサイズでシンプルな構造にもかかわらず、多くの助けを必要としています。
+デフォルトのテストモジュール`CommonModule`からサポートを受けることに加えて、次のようなものが必要です。
-* `NgModel` and friends in the `FormsModule` to enable two-way data binding
-* The `TitleCasePipe` from the `shared` folder
-* The Router services
-* The Hero data access services
+* `FormsModule`の`NgModel`など、双方向データバインディングを有効にする
+* `shared`フォルダの`TitleCasePipe`
+* ルーターサービス
+* ヒーローのデータアクセスサービス
-One approach is to configure the testing module from the individual pieces as in this example:
+1つのアプローチは、次の例のように、個々のピースからテストモジュールを設定することです。
-HELPFUL: Notice that the `beforeEach()` is asynchronous and calls `TestBed.compileComponents` because the `HeroDetailComponent` has an external template and css file.
+HELPFUL: `beforeEach()`が非同期であり、`TestBed.compileComponents`を呼び出していることに注意してください。なぜなら、`HeroDetailComponent`は外部テンプレートとcssファイルを持っているからです。
-As explained in [Calling `compileComponents()`](#calling-compilecomponents), these tests could be run in a non-CLI environment where Angular would have to compile them in the browser.
+[compileComponentsの呼び出し](#calling-compilecomponents)で説明されているように、これらのテストは、Angularがブラウザでそれらをコンパイルする必要がある、CLI以外の環境で実行することができます。
-### Import a shared module
+### 共有モジュールのインポート
-Because many application components need the `FormsModule` and the `TitleCasePipe`, the developer created a `SharedModule` to combine these and other frequently requested parts.
+多くのアプリケーションコンポーネントが`FormsModule`と`TitleCasePipe`を必要とするため、開発者は`SharedModule`を作成して、これらと他の頻繁に要求される部分を組み合わせました。
-The test configuration can use the `SharedModule` too as seen in this alternative setup:
+テスト設定では、次の例のように、`SharedModule`も使用できます。
-It's a bit tighter and smaller, with fewer import statements, which are not shown in this example.
+これは少しタイトで小さく、インポートステートメントが少なくなります。この例では示されていません。
-### Import a feature module
+### 機能モジュールのインポート
-The `HeroDetailComponent` is part of the `HeroModule` [Feature Module](guide/ngmodules/feature-modules) that aggregates more of the interdependent pieces including the `SharedModule`.
-Try a test configuration that imports the `HeroModule` like this one:
+`HeroDetailComponent`は、`SharedModule`など、相互依存する部分をさらにまとめた`HeroModule` [機能モジュール](guide/ngmodules/feature-modules)の一部です。
+次のような`HeroModule`をインポートするテスト設定を試してみましょう。
-Only the *test doubles* in the `providers` remain.
-Even the `HeroDetailComponent` declaration is gone.
+`providers`の*テストダブル*のみが残ります。
+`HeroDetailComponent`の宣言でさえなくなっています。
-In fact, if you try to declare it, Angular will throw an error because `HeroDetailComponent` is declared in both the `HeroModule` and the `DynamicTestModule` created by the `TestBed`.
+実際、宣言しようとすると、Angularはエラーをスローします。なぜなら、`HeroDetailComponent`は`HeroModule`と`TestBed`によって作成された`DynamicTestModule`の両方で宣言されているからです。
-HELPFUL: Importing the component's feature module can be the best way to configure tests when there are many mutual dependencies within the module and the module is small, as feature modules tend to be.
+HELPFUL: コンポーネントの機能モジュールをインポートすると、モジュール内に多くの相互依存関係があり、モジュールが小さい場合(機能モジュールは通常小さい)にテストを設定する最良の方法になる場合があります。
-## Override component providers
+## コンポーネントプロバイダーのオーバーライド
-The `HeroDetailComponent` provides its own `HeroDetailService`.
+`HeroDetailComponent`は独自の`HeroDetailService`を提供します。
-It's not possible to stub the component's `HeroDetailService` in the `providers` of the `TestBed.configureTestingModule`.
-Those are providers for the *testing module*, not the component.
-They prepare the dependency injector at the *fixture level*.
+`TestBed.configureTestingModule`の`providers`でコンポーネントの`HeroDetailService`をスタブすることはできません。
+それらは*テストモジュール*のプロバイダーであり、コンポーネントのプロバイダーではありません。
+それらは*フィクスチャレベル*で依存関係インジェクターを準備します。
-Angular creates the component with its *own* injector, which is a *child* of the fixture injector.
-It registers the component's providers \(the `HeroDetailService` in this case\) with the child injector.
+Angularは、コンポーネントを*独自の*インジェクターで作成します。これは、フィクスチャインジェクターの*子*です。
+これは、コンポーネントのプロバイダー(この場合は`HeroDetailService`)を子インジェクターに登録します。
-A test cannot get to child injector services from the fixture injector.
-And `TestBed.configureTestingModule` can't configure them either.
+テストは、フィクスチャインジェクターから子インジェクターのサービスを取得できません。
+`TestBed.configureTestingModule`もそれらを設定することはできません。
-Angular has created new instances of the real `HeroDetailService` all along!
+Angularは、ずっと前から実際の`HeroDetailService`の新しいインスタンスを作成していました!
-HELPFUL: These tests could fail or timeout if the `HeroDetailService` made its own XHR calls to a remote server.
-There might not be a remote server to call.
+HELPFUL: これらのテストは、`HeroDetailService`がリモートサーバーに独自のXHR呼び出しを行う場合、失敗したり、タイムアウトしたりする可能性があります。
+呼び出すリモートサーバーがない可能性があります。
-Fortunately, the `HeroDetailService` delegates responsibility for remote data access to an injected `HeroService`.
+幸いなことに、`HeroDetailService`は、リモートデータアクセスの責任を注入された`HeroService`に委任しています。
-The [previous test configuration](#import-a-feature-module) replaces the real `HeroService` with a `TestHeroService` that intercepts server requests and fakes their responses.
+[前のテスト設定](#import-a-feature-module)は、実際の`HeroService`を`TestHeroService`に置き換えます。これは、サーバーリクエストをインターセプトし、その応答を偽造します。
-What if you aren't so lucky.
-What if faking the `HeroService` is hard?
-What if `HeroDetailService` makes its own server requests?
+もし、そんなに恵まれていなかったらどうでしょうか?
+`HeroService`を偽造するのが難しい場合はどうでしょうか?
+`HeroDetailService`が独自のサーバーリクエストを行う場合はどうでしょうか?
-The `TestBed.overrideComponent` method can replace the component's `providers` with easy-to-manage *test doubles* as seen in the following setup variation:
+`TestBed.overrideComponent`メソッドは、次のようなセットアップのバリエーションのように、コンポーネントの`providers`を管理しやすい*テストダブル*に置き換えることができます。
-Notice that `TestBed.configureTestingModule` no longer provides a fake `HeroService` because it's [not needed](#spy-stub).
+`TestBed.configureTestingModule`は、[不要になったため](#spy-stub)、偽の`HeroService`を提供しなくなっていることに注意してください。
-### The `overrideComponent` method
+### `overrideComponent`メソッド
-Focus on the `overrideComponent` method.
+`overrideComponent`メソッドに注目してください。
-It takes two arguments: the component type to override \(`HeroDetailComponent`\) and an override metadata object.
-The [override metadata object](guide/testing/utility-apis#metadata-override-object) is a generic defined as follows:
+これは、2つの引数を取ります。オーバーライドするコンポーネントタイプ(`HeroDetailComponent`)と、オーバーライドメタデータオブジェクトです。
+[オーバーライドメタデータオブジェクト](guide/testing/utility-apis#metadata-override-object)は、次のように定義された汎用型です。
@@ -957,10 +957,10 @@ type MetadataOverride = {
-A metadata override object can either add-and-remove elements in metadata properties or completely reset those properties.
-This example resets the component's `providers` metadata.
+メタデータオーバーライドオブジェクトは、メタデータプロパティの要素を追加および削除するか、それらのプロパティを完全にリセットできます。
+この例では、コンポーネントの`providers`メタデータをリセットします。
-The type parameter, `T`, is the kind of metadata you'd pass to the `@Component` decorator:
+型パラメーター`T`は、`@Component`デコレーターに渡すメタデータの種類です。
@@ -972,27 +972,27 @@ providers?: any[];
-### Provide a *spy stub* (`HeroDetailServiceSpy`)
+### *スパイスタブ*(`HeroDetailServiceSpy`)を提供する
-This example completely replaces the component's `providers` array with a new array containing a `HeroDetailServiceSpy`.
+この例では、コンポーネントの`providers`配列を、`HeroDetailServiceSpy`を含む新しい配列に完全に置き換えます。
-The `HeroDetailServiceSpy` is a stubbed version of the real `HeroDetailService` that fakes all necessary features of that service.
-It neither injects nor delegates to the lower level `HeroService` so there's no need to provide a test double for that.
+`HeroDetailServiceSpy`は、実際の`HeroDetailService`のスタブバージョンであり、そのサービスに必要なすべての機能を偽造します。
+これは、下位の`HeroService`を注入したり、委任したりしないため、そのためのテストダブルを提供する必要はありません。
-The related `HeroDetailComponent` tests will assert that methods of the `HeroDetailService` were called by spying on the service methods.
-Accordingly, the stub implements its methods as spies:
+関連する`HeroDetailComponent`のテストは、サービスメソッドをスパイすることで、`HeroDetailService`のメソッドが呼び出されたことをアサートします。
+それに応じて、スタブはメソッドをスパイとして実装します。
-### The override tests
+### オーバーライドテスト
-Now the tests can control the component's hero directly by manipulating the spy-stub's `testHero` and confirm that service methods were called.
+これでテストは、スパイスタブの`testHero`を操作することでコンポーネントのヒーローを直接制御し、サービスメソッドが呼び出されたことを確認できます。
-### More overrides
+### さらなるオーバーライド
-The `TestBed.overrideComponent` method can be called multiple times for the same or different components.
-The `TestBed` offers similar `overrideDirective`, `overrideModule`, and `overridePipe` methods for digging into and replacing parts of these other classes.
+`TestBed.overrideComponent`メソッドは、同じコンポーネントまたは異なるコンポーネントに対して複数回呼び出すことができます。
+`TestBed`はこれらの他のクラスの一部を掘り下げて置き換えるために、`overrideDirective`や`overrideModule`、`overridePipe`などの類似のメソッドを提供します。
-Explore the options and combinations on your own.
+これらのオプションと組み合わせを自分で調べてみてください。