I am writing a unit test for one of the methods that instantiate a class new THREE.WebGLRenderer’ and throws an Error: Error creating WebGL context`
public init(element: HTMLElement) {
this.renderer = new THREE.WebGLRenderer({antialias: true});
}
so I decided to mock THREE.WebGLRenderer as
jasmine.createSpy('THREE.WebGLRenderer').and.returnValue(mockRenderer);
but when I call init method it again instantiates new THREE.WebGLRenderer and throws the same error.
Someone please suggest to fix the error or help me to mock it.