Testing Angular 2 Component with createEmbeddedView

I have a component with a template that conditionally looks like this:

@Component({
    selector: "presentation",
    template: "<template #tpl><!-- HTML --></template>"
})
export class Presentation implements AfterViewInit {

    @ViewChild('tpl') template: TemplateRef<any>;
    constructor(private view: ViewContainerRef) {}

    ngAfterViewInit() {
       this.view.createEmbeddedView(this.template); 
    }
}

      

I am trying to write a test, but as soon as I call

it("should launch card in practice mode", () => {
    fixture.detectChanges();
}

      

I get:

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked

      

What am I doing wrong?

+3


source to share





All Articles