twolfson / karma-electron

Karma launcher and preprocessor for Electron
The Unlicense
59 stars 21 forks source link

Custom launcher `require` mechanism doesn't work #40

Closed jushar closed 5 years ago

jushar commented 5 years ago

Description After updating my application to Electron 5, I needed to use the workaround in https://github.com/twolfson/karma-electron/issues/38#issuecomment-491510277 to enable the nodeIntegration.

Unfortunately, I can't get the require field within the customLaunchers property to work. It always just outputs:

12 06 2019 11:20:45.649:INFO [karma-server]: Karma v4.0.1 server started at http://0.0.0.0:9876/
12 06 2019 11:20:45.650:INFO [launcher]: Launching browsers CustomElectron with concurrency unlimited
12 06 2019 11:20:45.664:INFO [launcher]: Starting browser Electron 
12 06 2019 11:20:46.030:ERROR [launcher]: Cannot start Electron
12 06 2019 11:20:46.030:ERROR [launcher]: Electron stdout:
12 06 2019 11:20:46.030:ERROR [launcher]: Electron stderr:
12 06 2019 11:20:46.105:INFO [launcher]: Trying to start Electron again (1/2).

Reproduction (1) Clone https://github.com/Jusonex/karma-electron-testapp (2) npm install (3) npm test The mentioned repository contains only a default Angular installation and https://github.com/Jusonex/karma-electron-testapp/commit/66a173d8ffb3d220cd8ba4b24d0fc5f81e14ad25.

Additional Notes

twolfson commented 5 years ago

The provided repo seems to be missing preprocessors and client.useIframe as documented in our README. Can you try adding those?

https://github.com/twolfson/karma-electron/tree/6.1.1#getting-started

https://github.com/Jusonex/karma-electron-testapp/blob/66a173d8ffb3d220cd8ba4b24d0fc5f81e14ad25/src/karma.conf.js

Closing issue pre-emptively

jushar commented 5 years ago

Actually, I already have those flags in my production app.

I also added them to the testapp (https://github.com/Jusonex/karma-electron-testapp/commit/5dfe5f9fcd6e22f1e095de546f81bfee833bf298) now, but the issue remains the same.

The same applies to #41.

twolfson commented 5 years ago

Ah, I understand the issue now. Sorry for jumping to that assumption. I don't have time to clone/install/etc the test repo at the moment. I'm pretty confident this is a path issue inside the test repo as we have a test for require:

https://github.com/twolfson/karma-electron/blob/6.1.1/test/integration-test/karma.conf.js#L73-L76

Can you mess around with the path some more? e.g. Debug what path we think it should load vs the one it's receiving

twolfson commented 5 years ago

After releasing extended webPreferences support, we discovered that Windows had an issue with any spawn parameters after a URL (e.g. http://localhost:3000/?1234) for Electron@3 and later. This only showed up due to usage with require previously which would append a --require parameter after the URL parameter

We've patched this issue and released it in 6.3.0. Sorry for the inconvenience and thank you for your attempt to report it