Error: “component cannot define both template and templateUrl”

Error: “component cannot define both template and templateUrl”
0.0 0


Repost from StackOverflow. Hope that’s ok.

I have some karma/phantomjs tests that used to work but now give me this error for every component even though the components do not in fact define both template and templateUrl.

I don’t know whether it’s related but I am also getting many reports of 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 had made a lot of changes without running tests very often.

If you can think of a possible solution or even a way to debug this kind of test in my kind of project, I would be very happy.

The repository is here

    selector: 'jhi-activate',
    templateUrl: './activate.component.html'
export class ActivateComponent implements OnInit {

and the compiled js looks like

ActivateComponent = __decorate([
        selector: 'jhi-activate',
        template: __webpack_require__("./src/main/webapp/app/account/activate/activate.component.html")
    __metadata("design:paramtypes", [activate_service_1.Activate,
], ActivateComponent);
exports.ActivateComponent = ActivateComponent;

This is from the test log. If you need to see all of it let me know. I’m not yet allowed to post a question with 3 links.

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
	forEach@[native code]

The error is thrown 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`);