Error: "component cannot define both template and templateUrl"
Error: "component cannot define both template and templateUrl"
我有一些 karma/phantomjs 测试曾经有效,但现在每个组件都给我这个错误,即使这些组件实际上并没有同时定义模板和 templateUrl。
我不知道它是否相关,但我也收到很多关于此错误的报告:
Error: <spyOn> : could not find an object to spy upon for find()
Usage: spyOn(<object>, <methodName>) in /Users/Dan/work/bernierebuttals/gba/node_modules/jasmine-core/lib/jasmine-core/jasmine.js (line 4304)
我同时注意到两者,但我经常在没有 运行 测试的情况下做出很多更改。
如果你能想到一个可能的解决方案,甚至是在我这种项目中调试这种测试的方法,我会很高兴。
存储库是 here
...
@Component({
selector: 'jhi-activate',
templateUrl: './activate.component.html'
})
export class ActivateComponent implements OnInit {
...
编译后的js看起来像
ActivateComponent = __decorate([
core_1.Component({
selector: 'jhi-activate',
template: __webpack_require__("./src/main/webapp/app/account/activate/activate.component.html")
}),
__metadata("design:paramtypes", [activate_service_1.Activate,
shared_1.LoginModalService,
router_1.ActivatedRoute])
], ActivateComponent);
exports.ActivateComponent = ActivateComponent;
测试日志为here
...
PhantomJS 2.1.1 (Mac OS X 0.0.0) Component Tests ActivateComponent calls activate.get with the key from params FAILED
Failed: 'ActivateComponent' component cannot define both template and templateUrl
normalizeTemplate@spec/entry.ts:62868:209
_loadDirectiveMetadata@spec/entry.ts:63811:92
spec/entry.ts:64007:76
forEach@[native code]
loadNgModuleDirectiveAndPipeMetadata@spec/entry.ts:64006:48
spec/entry.ts:75202:94
...
抛出
...
if (prenormData.template != null) {
if (prenormData.templateUrl != null) {
throw syntaxError(
`'${stringify(prenormData.componentType)}' component cannot define both template and templateUrl`);
}
...
这是由 Angular 4.1.3 中的重大更改引起的,并已通过 update to jhipster tests by @sendikumarn
修复
我有一些 karma/phantomjs 测试曾经有效,但现在每个组件都给我这个错误,即使这些组件实际上并没有同时定义模板和 templateUrl。
我不知道它是否相关,但我也收到很多关于此错误的报告:
Error: <spyOn> : could not find an object to spy upon for find()
Usage: spyOn(<object>, <methodName>) in /Users/Dan/work/bernierebuttals/gba/node_modules/jasmine-core/lib/jasmine-core/jasmine.js (line 4304)
我同时注意到两者,但我经常在没有 运行 测试的情况下做出很多更改。
如果你能想到一个可能的解决方案,甚至是在我这种项目中调试这种测试的方法,我会很高兴。
存储库是 here
...
@Component({
selector: 'jhi-activate',
templateUrl: './activate.component.html'
})
export class ActivateComponent implements OnInit {
...
编译后的js看起来像
ActivateComponent = __decorate([
core_1.Component({
selector: 'jhi-activate',
template: __webpack_require__("./src/main/webapp/app/account/activate/activate.component.html")
}),
__metadata("design:paramtypes", [activate_service_1.Activate,
shared_1.LoginModalService,
router_1.ActivatedRoute])
], ActivateComponent);
exports.ActivateComponent = ActivateComponent;
测试日志为here
...
PhantomJS 2.1.1 (Mac OS X 0.0.0) Component Tests ActivateComponent calls activate.get with the key from params FAILED
Failed: 'ActivateComponent' component cannot define both template and templateUrl
normalizeTemplate@spec/entry.ts:62868:209
_loadDirectiveMetadata@spec/entry.ts:63811:92
spec/entry.ts:64007:76
forEach@[native code]
loadNgModuleDirectiveAndPipeMetadata@spec/entry.ts:64006:48
spec/entry.ts:75202:94
...
抛出
...
if (prenormData.template != null) {
if (prenormData.templateUrl != null) {
throw syntaxError(
`'${stringify(prenormData.componentType)}' component cannot define both template and templateUrl`);
}
...
这是由 Angular 4.1.3 中的重大更改引起的,并已通过 update to jhipster tests by @sendikumarn
修复