Angular Unit Test Ngif, You can use the ngOnInit as long as you set the "static" value of the viewchild to true.