Closed Nashorn closed 3 years ago
It appears that the ReferenceError is due to SharedArrayBuffer not being defined/available in Electron 14.0.0 so you should test for "undefined", not typeof "function":
### FIX:
const sabByteLengthGetter =
typeof SharedArrayBuffer != "undefined" ?
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get :
null;
The fix for this is very simple and does not break in nodejs: Instead of:
const sabByteLengthGetter =
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get;
Use:
const sabByteLengthGetter =
typeof SharedArrayBuffer != "undefined" ?
Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get :
null;
and there are many of us who are running jsdom in a nodejs environment within Electron shell. I don't understand why you would not just apply the above condition. Could this ticket be reopened?
Soultion for anyone who upgrades Electron to v14 (as JSDOM breaks in latest Nodejs) is to use: Linkedom (https://github.com/WebReflection/linkedom). Far superior, lite, blazing fast, low on memory and is a direct jsdom replacement.
After upgrading to Electron 14.0.0, JSDOM breaks at the require() statement (If require() is commented, the app loads fine):
const jsdom = require("jsdom");
With the following error:
It appears to be originating from the dependency 'whatwg-url'. This was fixed in webidl-conversions@7.0.0 but whatwg-url was not updated to use the latest dependency.