vendredi 16 février 2018

how to define elements in template sp that testing in jasmine would be correct in angular 2 component

I am trying to test a component in Angular using Jasmine. the test is simple, it just needs to verify that the component is created.

it('AppComponent should be created', () => { expect(component).toBeTruthy(); });

It is a default spec which is created automatically inside spec file if you use angular cli. My problem is that the html file of the component has some elements that are not regular tags, that is custom.

<app-header></app-header> 

The question is how can I let Jasmine know about them, where they came from, or how to add links etc, so that errors like

Failed: Template parse errors: 'app-header' is not a known element: 1. If 'app-header' is an Angular component, then verify that it is part of this module.

won't show up in Karma debug page. How to verify?

Aucun commentaire:

Enregistrer un commentaire