[英]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外部模板,我打电话configureTestingModule后compileComponents。
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.