Error: "component cannot define both template and templateUrl"

I have some karma / phantomjs tests that worked before, but now give me this error for each component, even though components don't actually define both template and templateUrl.

I don't know if this is related, but I also get a lot of messages about this error:

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)

      

I noticed both at the same time, but I made so many changes without running tests very often.

If you can think of a possible solution or even debug such a test in your project, I would be very pleased.

The repository is here

...
@Component({
    selector: 'jhi-activate',
    templateUrl: './activate.component.html'
})
export class ActivateComponent implements OnInit {
...

      

and the compiled js looks like

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;

      

Test log 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
...

      

The error is caused by this line of Angular code

...
if (prenormData.template != null) {
  if (prenormData.templateUrl != null) {
    throw syntaxError(
        `'${stringify(prenormData.componentType)}' component cannot define both template and templateUrl`);
  }
...

      

+3


source to share


1 answer


This was triggered by a change in Angular 4.1.3 and fixed with update for jhipster @sendikumarn tests



+2


source







All Articles