Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 错误:";组件不能同时定义模板和模板URL;_Angular_Jasmine_Phantomjs_Karma Runner_Jhipster - Fatal编程技术网

Angular 错误:";组件不能同时定义模板和模板URL;

Angular 错误:";组件不能同时定义模板和模板URL;,angular,jasmine,phantomjs,karma-runner,jhipster,Angular,Jasmine,Phantomjs,Karma Runner,Jhipster,我曾经做过一些karma/phantomjs测试,但是现在每个组件都出现了这个错误,尽管这些组件实际上并没有同时定义模板和模板URL 我不知道是否与此相关,但我也收到了许多关于此错误的报告: Error: <spyOn> : could not find an object to spy upon for find() Usage: spyOn(<object>, <methodName>) in /Users/Dan/work/bernierebuttals

我曾经做过一些karma/phantomjs测试,但是现在每个组件都出现了这个错误,尽管这些组件实际上并没有同时定义模板和模板URL

我不知道是否与此相关,但我也收到了许多关于此错误的报告:

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)
编译后的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;
测试日志是

错误是由


这是由Angular 4.1.3中的一个突破性更改引起的,并通过

的to jhipster测试进行了修复。您是否尝试过删除已编译的JS文件并重新编译它们?也许在编译的文件中有一个旧的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;
...
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`);
  }
...