Karma not breaking on missing component

Viewed 270

We are seeing errors in tests when child components are not imported/declared, however the tests are not failing. This has over time caused that these tests have been added to the codebase. enter image description here

We'd like to ensure that these actually break the tests though so that we can prevent them from being committed.

Is there a way we can make this fail the tests?

How to reproduce:

  • Create new project
  • Create new module and component child (and export component)
  • Import child module in app module
  • Add <app-child></app-child> to app.component.html

ng run build/start works fine, however ng run test throws:

ERROR: 'NG0304: 'app-child' is not a known element:
1. If 'app-child' is an Angular component, then verify that it is part of this module.
2. If 'app-child' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.'
Chrome Headless 88.0.4324.150 (Mac OS 11.2.1): Executed 1 of 2 SUCCESS (0 secs / 0.028 secs)
ERROR: 'NG0304: 'app-child' is not a known element:
1. If 'app-child' is an Angular component, then verify that it is part of this module.
Chrome Headless 88.0.4324.150 (Mac OS 11.2.1): Executed 2 of 2 SUCCESS (0.051 secs / 0.037 secs)
TOTAL: 2 SUCCESS
0 Answers
Related