我是相當新的角2。如何單位測試,如果角2組件包含另一個組件
我有一個組件,它的模板中又有一些其他組件。
如何編寫單元測試以檢查我的父組件是否包含其他組件。
提到一個示例或將我引導到資源將非常有幫助。
MyComponent.ts:
import { Component } from '@angular/core';
@Component({
selector: 'my-component',
templateUrl: `<div>
<other-component></other-component>
</div>`
})
export class MyComponent{
}
OtherComponent.ts:
import { Component } from '@angular/core';
@Component({
selector: 'other-component',
templateUrl: `<div>
<h1>Other Component</h1>
</div>`
})
export class OtherComponent{
}
這並沒有真正回答他們有問題。他們希望確保模板中存在的組件不會從外部組件中測試內部組件或獨立測試組件。 –