Custom attribute directive works fine with "ng serve", but causes template parse error with "ng test"

6 views
Skip to first unread message

Sebastian Bechtold

unread,
Jun 19, 2018, 11:40:38 AM6/19/18
to Angular and AngularJS discussion

Hello!

I am new to Angular and just wrote my first attribute directive. I created the directive with "ng generate directive logClick", added my code, and it works perfectly fine when I run the application with "ng serve". No errors.

When I push my code to our Git repository, our CI system runs the following command:

 "ng test --single-run=true --browser PhantomJS --watch=false --code-coverage"

This fails with the following error message:

ERROR: 'Unhandled Promise rejection:', 'Template parse errors: Can't bind to 'appLogClick' since it isn't a known property of 'button'.

I have already searched for this error on the web, and while I found several posts about that error message in general, none referred to a case similar to mine, and none helped to solve the problem. A colleague suggested to try "ChromeHeadless" instead of "PhantomJS". I tried this, the error remains.

What am I doing wrong?

Sander Elias

unread,
Jun 22, 2018, 2:21:59 PM6/22/18
to Angular and AngularJS discussion
Hi Sebastian,

Sounds like that your directive is not pulled in by your test. Are you sure you added it to your test-module?

Regards
Sander
Reply all
Reply to author
Forward
0 new messages