I have a very weird situation trying to test when nodeIntegration is set to false.
Error: unknown error: Cannot read property 'electron' of undefined
at execute(<Function>) - D:\projekty\meteor-desktop\node_modules\spectron\lib\api.js:64:26
here it fails because process does not have versions...
Api.prototype.getVersion = function () {
return this.app.client.execute(function () {
if (typeof process === 'object') return process.versions.electron
}).then(getResponseValue)
}
Here is my preload:
process.once('loaded', () => {
let devtron = null;
try {
devtron = require('devtron'); // eslint-disable-line global-require
global.__devtron = { require, process }; // eslint-disable-line no-underscore-dangle
} catch (e) {
// If that fails, then probably this is production build and devtron is not available.
}
if (process.env.NODE_ENV === 'test') {
global.electronRequire = require;
}
});
When I add global.process = process it works again:
I have a very weird situation trying to test when
nodeIntegration
is set tofalse
.here it fails because
process
does not haveversions
...Here is my preload:
When I add
global.process = process
it works again:Grepping code I have found this https://github.com/electron/electron/blob/master/lib/renderer/init.js#L123 but I have no idea whether this can be related.