簡體   English   中英

為什么 Angular2 TestBed 的 compileComponents 找不到我的模板?

[英]Why does Angular2 TestBed's compileComponents can't find my templates?

我有一個組件,我們稱之為 MyComponent。 它使用 my.component.html 作為 templateUrl。

@Component({
  selector: "my-component",
  templateUrl: "./my.component.html",
  styleUrls: ["./my.component.css"]
})

我正在為此組件編寫測試(規范)。 因為,it'susing外部模板,我打電話configureTestingModulecompileComponents。

beforeEach(async(() => {
    TestBed.configureTestingModule({
        declarations: [ MyComponent ]
    })
    .compileComponents()
}));

在運行測試時,我收到此錯誤 -

無法加載 my.component.html

該應用程序在npm start 下運行絕對沒問題,並按原樣提供模板。 這只是在給定設置下失敗的測試。 我做錯了什么?

我正在關注本教程

在我的 webpack 測試配置中,我只有awesome- typescript -loader ,我只需要添加angular2-template-loader

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM