Closed Zyie closed 1 year ago
Just ran into another issues. IS there a way to enable enable-unsafe-webgpu
?
I can hack this in by adding app.commandLine.appendSwitch('enable-unsafe-webgpu')
to JestWorkerRPC
But is there a config or env I can set?
Never used DEBUG_MODE with jest-electron. This simply shows the electron window and then runs the tests? And it stays open after the tests are finished, no matter if they failed or not?
Just tried to disable the hiding and closing of the windows. You will get a window for every test file and the window is empty and the console shows nothing. Not sure for what this can be useful. If jest-electron does more magic when DEBUG_MODE is set then I'm not sure if I can do the same in jest-electron-runner.
I had the same problem and worked around it with the two lines added to runInBrowserWindow (search for electron/remote):
24 async function runInBrowserWindow(testData) {
25 try {
26 const workerID = (0, utils_1.makeUniqWorkerId)();
27 require('@electron/remote/main').initialize();
28 const win = new electron_1.BrowserWindow({
29 show: false,
30 webPreferences: {
31 nodeIntegration: true,
32 contextIsolation: false,
33 enableRemoteModule: true
34 }
35 });
36 require("@electron/remote/main").enable(win.webContents)
37 win.webContents.on("console-message", (event, level, message, line, sourceId) => {
38 if (/\bdeprecated\b/i.exec(message) != null) {
39 // Ignore deprecation warnings
This is obviously extremely hacky and it would be great to upstream this patch.
Thank you for the pull requests. @neojski is the pull request #10 working for you as well? I would prefer this one.
And a question to all of you: Can you give me an example how do you use this feature? I never needed this and now I wonder how it actually is useful. Just calling currentWindow.open()
in a unit test doesn't really do anything because the window is closed immediately when the test is finished. So to actually see the window you have to wait in the test and for this to work you most likely have to increase Jests test timeout because otherwise the window will close after 5 seconds. So how do you use this? Or are you running jest in debug mode and set a breakpoint?
And while the window is open the debug console in it is broken. It doesn't show messages (Most likely because messages are redirected to Jest) but it also doesn't accept input which is strange. Did this work in the past with the original electron jest runner?
@neojski Your second problem (electron process is not killed when aborting the tests) should be fixed since jest-electron-runner v29.1.0. I had the same problem on Linux and finally fixed it. I hope this is the same problem you have on MacOS.
Edit: Sorry, the question wasn't from @neojski , it was from @Zyie . :sweat_smile:
Yes, #10 works for me. I'd be happy with it to be released and #9 closed. Thanks!
Just ran into another issues. IS there a way to enable
enable-unsafe-webgpu
?I can hack this in by adding
app.commandLine.appendSwitch('enable-unsafe-webgpu')
toJestWorkerRPC
But is there a config or env I can set?
This is fixed in v29.2.0. All Electron command line options can now be specified in test environment options in the Jest config or with the ELECTRON_OPTIONS environment variable.
See README for details.
Hi @kayahr
I'm currently trying to convert PixiJS from using jest-electron to this package. I am having a couple of issues.
Debug UI
One thing we liked about
jest-electron
is that you could easily show the UI withDEBUG_MODE=1
Looking at the readme I've tried adding
require('electron').remote.getCurrentWindow().show();
to a setup file but i get this errorTypeError: Cannot read properties of undefined (reading 'getCurrentWindow')
What is the recommended way of debugging tests with this package?
I have this branch ready that should demonstrate the issue I'm having:
https://github.com/pixijs/pixijs/tree/chore/jest-update
Process not exiting on MacOS
On my mac the electron icon appears in my dock. If i cancel the terminal before the tests end the process still runs and i have to manually quit the electron app.
If i let the tests finish then the app closes by itself. So it is just an issue with cancelling early