DevExpress / testcafe-browser-provider-electron

This is the Electron browser provider plugin for TestCafe.
https://testcafe.io
MIT License
49 stars 30 forks source link

Add support for Electron 28 #110

Open bigorn0 opened 8 months ago

bigorn0 commented 8 months ago

Hello,

while upgrading my application to latest Electron 28 latest release, I wanted to validate my test tooling and i noticed that Testcafe integration doesn't work anymore. It only opens the default Electron page and displays the help command output in logs.

I started to try to find a workaround (or at least the root cause) but so far no luck for now

Note that it works perfectly with Electron 27.

Could you please check?

Thanks!

github-actions[bot] commented 8 months ago

We appreciate you taking the time to share information about this issue. We reproduced the bug and added this ticket to our internal task queue. We'll update this thread once we have news.

thomas-jakemeyn commented 8 months ago

We managed to make the TestCafe tests start with Electron 28 by patching src/injectable/index.js. We have modified the existing logic below:

// src/injectable/index.js, line 19
const isMain = args[2];
const isNotBrowserInitMainModule = isMain && !isBrowserInitModule(args[0]);

if (isNotBrowserInitMainModule) {
  ...
}

as followed:

// src/injectable/index.js, line 19
const isMain = args[2];
const isNotBrowserInitMainModule = isMain && !isBrowserInitModule(args[0]);
const isNotBrowserInitMainModuleAsOfElectron28 = args[0] === 'electron' && !args[1];
const runDecorator = isNotBrowserInitMainModule || isNotBrowserInitMainModuleAsOfElectron28;

if (runDecorator) {
  ...
}

We have validated this patch by running npm run test in this repository after upgrading the following dev dependencies:

thomas-jakemeyn commented 3 months ago

If you are looking for a solution to make the plugin work for a more recent version of Electron, then have a look at #119.