I am using angular 6.1.6 and really new to Karma. When I run ng test,
the result shows some elements (please see screenshot here). Can I hide them/remove from my testing result?
Thank you.
I am using angular 6.1.6 and really new to Karma. When I run ng test,
the result shows some elements (please see screenshot here). Can I hide them/remove from my testing result?
Thank you.
I got another answer.
Putting this in the beforeEach function works well
fixture.debugElement.nativeElement.style.visibility = "hidden";
and it would hide the flashing component when testing.
It looks like your test is adding things directly to the dom, which is non-standard (though there are some instances where this is a good idea). In general, your tests should not attach any dom to the document object (eg- by calling document.querySelector('#foo').appendChild(...). If you create dom elements, you should avoid attaching them to the document.
If you do attach dom elements to the document, the simplest way to remove them is in an afterEach block in your describe spec, like this:
afterEach(() => document.querySelector('#my-element').remove());