Unit Testing socket.io in Angular
问题 I am trying to unit test an angular service in my application, which creates socket.io client. My service looks something like this: export class SocketService { private name: string; private host: string = window.location.protocol + "//" + window.location.hostname + ":3000"; socket: io.Socket; constructor() { } subscribeEvent(name: string): Observable<IJobResp> { this.setup(name); return new Observable(observer => { this.socket.on('job', val => observer.next(val)) }) } private setup(name: