I am trying to unit test some code that uses the webSocket
function from rxjs6. I have tried to spy on the webSocket function by doing the following (as recommended here): -
import * as rxJsWebSocket from 'rxjs/webSocket';
subject = new Subject();
webSocketSpy = spyOn(rxJsWebSocket, 'webSocket').and.returnValue(<any>subject);
but I got the error: -
Error: <spyOn> : webSocket is not declared writable or has no setter
Is there any other way to achieve this or is there a workaround for the error?
I've also tried ts-mock-imports with no success.