I have an Angular 6 app and writing some unit tests trying to determine if an element is visible or not based solely on the boolean result of an *ngIf directive
If the element is hidden, then it wont be rendered inside the dom.
You can check
expect(fixture.debugElement.query(By.css('.header'))).toBeUndefined();
EDIT : toBeNull() works better in the above case
expect(fixture.debugElement.query(By.css('.header'))).toBeNull();
And also you have a syntax error while fetching the button element. nativeElement is not a function.
Change it this way :
const button = fixture.debugElement.query(By.css('button')).nativeElement;