This unit test
it('should invoke copy method', fakeAsync(() => {
spyOn(testClipboardService, 'copy');
linkEl = fixture.debugElement.query(By.css('.mat-raised-button')).nativeElement;
linkEl.click();
expect(testClipboardService.copy).toHaveBeenCalled();
}));
it successfully passed but in console I have an error which provoked this line:
linkEl.click();
I don't understand why
'ERROR', TypeError{ngDebugContext: DebugContext_{view: Object{def: ..., parent: ..., viewContainerParent: ..., parentNodeDef: ..., context: ..., component: ..., nodes: ..., state: ..., root: ..., renderer: ..., oldValues: ..., disposables: ..., initIndex: ...}, nodeIndex: 0, nodeDef: Object{nodeIndex: ..., parent: ..., renderParent: ..., bindingIndex: ..., outputIndex: ..., checkIndex: ..., flags: ..., childFlags: ..., directChildFlags: ... etc
Thanks in advance
In my case, I was able to get rid of the error by adding the NoopAnimationsModule to my imports when configuring testbed. Based on what I found, you are probably missing an import when running your tests.
Example:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MyAwesomeComponent ],
imports: [
NoopAnimationsModule, // I had to add this
FormsModule,
RouterTestingModule
]
})
.compileComponents();
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With