I am trying to use spector.js npm package with cypress to test WebGL. When i run the test it gives an error 'e is null'

I am trying to capture the JSON using spector.js inside the cypress.
var spector = new SPECTOR.Spector();
spector.onCapture.add((capture) => { // Do something with capture. var myEvent = new CustomEvent("SpectorOnCaptureEvent", { detail: { captureString: JSON.stringify(capture) } }); document.dispatchEvent(myEvent); });
var canvas = document.getElementById("renderCanvas");
spector.captureCanvas(canvas);