简体   繁体   中英

Figure out which Angular component issues the error during Karma test

When running my Karma tests, I get lots of errors (which are in fact warnings) like this:

ERROR: 'NG0304: 'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'

Now, this is easy to fix once you know which component complains about the unknown element. The problem is the application has dozens of them and Karma's output doesn't provide any clue as to where the problem arises.

How can I find out which component causes the error, without needing to selectively run tests against each of them?

I see that in recent Karma versions (I'm using Karma v6.4.0) this has finally been resolved:

ERROR: 'NG0304: 'fa-icon' is not a known element (used in the 'ApiKeyManagerComponent' component template):
1. If 'fa-icon' is an Angular component, then verify that it is a part of an @NgModule where this component is declared.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'

The addition of (used in the 'ApiKeyManagerComponent' component template) is exactly what I was after.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM