Open
Description
Is there any way to mock electron modules from spectron?
Currently, I have to add all my mocks to the main process directly in my application code. So my mocks get shipped with the app, which is far from ideal. I remove the code in my build process but it would be much better to have the mocks added by spectron instead.
My current setup looks something like the following:
tests/e2e.js
// ...
new Application({
path: electronPath,
env: { RUNNING_IN_SPECTRON: '1' },
args: ['.'],
});
// ...
main.js
const electron = require('electron');
// ...
if (process.env.RUNNING_IN_SPECTRON) {
electron.dialog.showOpenDialog = (opts, cb) => {
if (opts.title === 'Choose Site Folder') {
cb(['/Users/dave/lorem/ipsum/My Site']);
}
};
}
// ...