2
:アンギュラ4 - コンポーネントが別のコンポーネントを持っているときのテスト、私は角度の私のアプリケーションにテストを適用しています
:これは私のhtmlファイル(ページ-ない-found.component.html)はng test
です
<menu></menu>
<div>
<h4>
ERROR 404 - PÁGINA NO ENCONTRADA
</h4>
</div>
ng testを実行すると、コンポーネントによってエラーが発生します。
このファイル仕様(ページ未found.component.spec.ts)
import { MenuComponent } from '../menu/menu.component';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PageNotFoundComponent, MenuComponent ]
})
.compileComponents();
}));
これは成分符号(ページ-ない-found.component.ts)
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-page-not-found',
templateUrl: './page-not-found.component.html',
styleUrls: ['./page-not-found.component.css']
})
export class PageNotFoundComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
あります
これはエラーです:
Error: No provider for ActivatedRoute!
問題を教えてください。ありがとう
はい、必要です、それはヘッダーです、私はテストするつもりです、私はあなたに感謝 – Eladerezador
しかし、この練習をよく理解していない、メニューはコンポーネントですが、それは私の角度routesファイル – Eladerezador
それは正常に動作しています、私はファイルts模擬(activated-route.ts)を作成しましたが、私はundestandをなぜですか?私はこのファイルがコンポーネントのPageNotFoundComponentのhtmlにヘッダーコンポーネント(MenuComponent)をテストするために必要です、私はより多くのドキュメントを検索します – Eladerezador