Closed cpettet closed 2 years ago
I hadn't heard of that API before, it seems to be related to capturing media sources:
https://www.electronjs.org/docs/latest/api/desktop-capturer#desktopcapturergetsourcesoptions
I'm not sure we actually need to change this in karma-electron
. This repo is primarily intended for browser-only code, run through Electron for convenience of importing and screenshotting.
More importantly though, we have a hook for custom main
configuration through require
in launcher configuration:
https://github.com/twolfson/karma-electron/tree/7.1.0#launcher-configuration
https://github.com/twolfson/karma-electron/blob/7.1.0/lib/electron-launcher.js#L42-L47
Thus if anyone needs this functionality, then they can opt-in via the code from the Electron docs
Closing this PR eagerly. Glad to re-open if you feel I've missed something =) Thanks for raising the issue!
Info on this PR
According to the Electron Docs,
desktopCapturer.getSources
will only be available in the main process and will need to be exposed through IPC before being used in a renderer process. In order to test functions which depend on desktopCapturer.getSources in karma, the appropriate handler has to be created in the launcher.To access
desktopCapturer.getSources
in a renderer process, an accompanying preload script containing the following needs to be added.This PR is changing up the dependencies for readability to DRY code. It adds the event emitter listening for 'DESKTOP_CAPTURER_GET_SOURCES' which will allow testers to use the
desktopCapturer.getSources
method if needed.How to Test
Normal regression testing, I'm not sure about your process. You could also fire up karma with different Electron versions and run the following in the developer console. You should get some active windows and screens available for screen-sharing.
Issue Being Resolved
See this upcoming, breaking change.