Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support electron v8 #64

Closed
mrfelton opened this issue Apr 1, 2020 · 17 comments
Closed

Support electron v8 #64

mrfelton opened this issue Apr 1, 2020 · 17 comments

Comments

@mrfelton
Copy link

mrfelton commented Apr 1, 2020

Doesn't seem to work with electron v8. It's not able to properly start the app.

ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.

Here is the full output of the test run. Note this same setup works under electron v7.

$ cross-env DEBUG=testcafe* DISABLE_INIT=1 ELECTRON_USER_DIR_TEMP=1 testcafe --selector-timeout 60000 --assertion-timeout 60000 --screenshots ./screenshots --screenshots-on-fails electron:'./' ./test/e2e
⠸
  testcafe:browser-provider-electron:spawn:stderr Debugger listening on ws://127.0.0.1:58717/d506d6be-ff37-4ce9-b458-d7b11a9f1b45
  testcafe:browser-provider-electron:spawn:stderr For help, see: https://nodejs.org/en/docs/inspector +0ms
⠼
  testcafe:browser-provider-electron:spawn:stderr Debugger listening on ws://127.0.0.1:58717/d506d6be-ff37-4ce9-b458-d7b11a9f1b45
⠏
  testcafe:browser-provider-electron:spawn:stderr (electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false".  It will change to be "true" in Electron 9.  For more information please check https://github.com/electron/electron/issues/18397 +766ms
  testcafe:browser-provider-electron:spawn:stderr (node:40491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emit' of null
  testcafe:browser-provider-electron:spawn:stderr     at Client.sendInjectingStatus (/Users/tom/workspace/zap-desktop/node_modules/testcafe-browser-provider-electron/lib/ipc.js:498:25)
  testcafe:browser-provider-electron:spawn:stderr     at WebContents.loadURL (/Users/tom/workspace/zap-desktop/node_modules/testcafe-browser-provider-electron/lib/injectable/electron-mocks.js:110:17)
  testcafe:browser-provider-electron:spawn:stderr     at BrowserWindow.loadURL (electron/js2c/browser_init.js:635:29)
  testcafe:browser-provider-electron:spawn:stderr     at ZapController.init (/Users/tom/workspace/zap-desktop/dist/main.js:5805:25)
  testcafe:browser-provider-electron:spawn:stderr     at App.<anonymous> (/Users/tom/workspace/zap-desktop/dist/main.js:9116:7)
  testcafe:browser-provider-electron:spawn:stderr     at App.emit (events.js:215:7) +33ms
  testcafe:browser-provider-electron:spawn:stderr (node:40491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emit' of null
  testcafe:browser-provider-electron:spawn:stderr     at Client.sendInjectingStatus (/Users/tom/workspace/zap-desktop/node_modules/testcafe-browser-provider-electron/lib/ipc.js:498:25)
  testcafe:browser-provider-electron:spawn:stderr     at WebContents.loadURL (/Users/tom/workspace/zap-desktop/node_modules/testcafe-browser-provider-electron/lib/injectable/electron-mocks.js:110:17)
  testcafe:browser-provider-electron:spawn:stderr     at BrowserWindow.loadURL (electron/js2c/browser_init.js:635:29)
  testcafe:browser-provider-electron:spawn:stderr     at ZapController.init (/Users/tom/workspace/zap-desktop/dist/main.js:5805:25)
  testcafe:browser-provider-electron:spawn:stderr     at App.<anonymous> (/Users/tom/workspace/zap-desktop/dist/main.js:9116:7)
  testcafe:browser-provider-electron:spawn:stderr     at App.emit (events.js:215:7)
  testcafe:browser-provider-electron:spawn:stderr (node:40491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  testcafe:browser-provider-electron:spawn:stderr (node:40491) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  testcafe:browser-provider-electron:spawn:stderr (node:40491) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  testcafe:browser-provider-electron:spawn:stderr (node:40491) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.

Type "testcafe -h" for help.
error Command failed with exit code 1.
@Farfurix
Copy link
Contributor

Farfurix commented Apr 3, 2020

@mrfelton

Hello,

Thank you for reaching us. We will examine the possibility of adding the latest Electron version.

@mrfelton
Copy link
Author

mrfelton commented Apr 8, 2020

The issue seems to be related to this code:

sendInjectingStatus (status) {
this.client.emit(MESSAGES.getInjectingStatus, status);
}

When called from here:

ipc.sendInjectingStatus({ completed: true });

At the point this.client seems to be null.

@LavrovArtem
Copy link

Thank you for the research. This information was very helpful for us.

veado added a commit to thorchain/asgardex-electron that referenced this issue Apr 21, 2020
It's still failing. It seems more an issue of `testcafe-browser-provider` DevExpress/testcafe-browser-provider-electron#64
@veado
Copy link

veado commented Apr 23, 2020

@LavrovArtem May I ask you if there any updates to support Electron 8.x ?

@LavrovArtem
Copy link

We have not established any exact dates yet. Any personal estimate may be misleading, so I cannot currently tell you the precise date.

@steveetm
Copy link
Contributor

@veado created a PR, you can check it with my fork if you clone it and build with gulp then yarn add PathToLocallyClonedFork

@Dmitry-Ostashev
Copy link

@steveetm Thank you for your PR, we'll review it soon.

@lukechu10
Copy link

Hello, does this work with electron v9?

@mrfelton
Copy link
Author

mrfelton commented Jun 6, 2020

In my testing @lukechu10 it does work sometimes, but sometimes it leaves the window open indefinitely at the end of the test run which makes it impossible to use on a CI environment.

p.s. if you want a version of this that works with Electron 8.x you can use http://npmjs.com/@ln-zap/testcafe-browser-provider-electron which I created that includes the fix from #65 which has been merged here but not yet included in a new release.

@Dmitry-Ostashev
Copy link

@lukechu10 Currently, we don't have news about Electron v9 support.

@jakerobb
Copy link

jakerobb commented Jul 7, 2020

I see that @steveetm's PR was merged back in May. Any plans to cut a release with that change?

I also see that @mrfelton made a fork with the fix, but I'm a bit of a Node noob, and I guess I don't know how to include it. I tried npm install @ln-zap/testcafe-browser-provider-electron. When that didn't work, I reverted my changes and tried changing my devDependencies in package.json from:

"testcafe-browser-provider-electron": "0.0.14",

to

"@ln-zap/testcafe-browser-provider-electron": "0.0.15-alpha.3",

and running npm install, which did pretty much the same thing. Same result in both cases: no complaints from npm, but now testcafe doesn't know about the "electron" browser at all:

$ testcafe                                        
ERROR Unable to find the browser. "electron:." is not a browser alias or path to an executable file.

Type "testcafe -h" for help.
$ testcafe -b electron
ERROR The specified "electron" browser provider was not found.

Type "testcafe -h" for help.
$

I got the same results against Electron v8.1.1 (the version I was already using), 8.2.3 (the version specified by package.json in #65), and 8.3.4 (latest 8.x).

Am I doing something wrong? Are there troubleshooting steps I can take? I'm currently scouring testcafe's source code, trying to learn how it discovers browser provider plugins.

@jakerobb
Copy link

jakerobb commented Jul 7, 2020

I've now determined that the problem is the forked module name, combined with TestCafe's rigorous naming scheme for browser-provider plugins.

To load the plugin, TestCafe (browser/provider/pool.js::_getProviderModule) takes the passed-in module name electron and appends it to "testcafe-browser-provider-", then passes that to require(...). That attempts to load the regular, non-forked plugin, which I don't have installed.

I need it to call require("@ln-zap/testcafe-browser-provider-electron"). As such, I needed to specify that full string as the browser name in my .testcaferc.json file (or on the command line, if you're specifying the browser there). To anyone else trying to use @steveetm's fork, that's the trick!

@Farfurix
Copy link
Contributor

Farfurix commented Jul 8, 2020

@jakerobb

Hello,

I published a new version: v0.0.15.

In the case of any custom fork, you can use a specific scope of the installed electron provider module.

  "dependencies": {
    "@ln-zap/testcafe-browser-provider-electron": "0.0.15-alpha.3",

Command:

"test": "testcafe \"@ln-zap/electron:./\" ./test/test.js"

Test imports:

import { setElectronDialogHandler } from '@ln-zap/testcafe-browser-provider-electron';

Or, you can simply install the @ln-zap/testcafe-browser-provider-electron module under the testcafe-browser-provider-electron alias:

npm i testcafe-browser-provider-electron@npm:@ln-zap/testcafe-browser-provider-electron

In this case, you don't need to use any scope in your commands and imports.

@tarjei
Copy link

tarjei commented Oct 2, 2020

Any news on when the 0.0.15 release will be done?

@Farfurix
Copy link
Contributor

Farfurix commented Oct 2, 2020

@tarjei

Hello,

I fixed the GitHub Electron provider version. Anyway, you can install the [email protected] version from npm.

@trungutt
Copy link

I have my app with [email protected] and [email protected]. I think we should close this issue

@Farfurix
Copy link
Contributor

@trungutt

Hello,

Yes. Since we merged these changes, we can close it.

If anyone encounters issues with Electron 8, please feel free to open a new bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants