Closed neojski closed 5 years ago
Hi @neojski I managed to do what you want to do, so maybe I can help:
You can execute remote.getCurrentWindow().show()
in your test to open the electron window. I use that for debugging. I think it is possible to take screenshot even if the window is not shown.
I render a react component using enzyme
and then to html using enzymes render
function. I attach the rendered html to the document body. After that I wait a little while for the rendering to complete, since I don't know yet how to check if it finished rendering.
The capturePage
call looks like this:
remote.getCurrentWebContents().capturePage(image => {
expect(image.toPNG()).toMatchImageSnapshot(})
})
Maybe you can show us what how your test setup looks like?
Best regards
Hi @mfpi, thanks for your reply. So, remote.getCurrentWindow().show()
is great for debugging.
I've also learned that the getCurrentWebContests().capturePage
only works under two conditions:
show()
firstshow()
(like a second).Do you experience similar issues?
Oh, I was wrong. It's only the number 2. that's important and not the show()
itself. And, I think, it's not even electon's fault but it's my rendering using react that's not synchronous. I think this solves all of my problems.
I don't know yet how to check if it finished rendering
I've been fighting with this recently and the best bet I have so far is to insert some magical pixel and poll to see if it's rendered. If you figure out how to do it better please let me know :-)
I have tests that use advanced browser API (svg) so I find jest-electron-runner essential to run my tests. However, I would like to be able to occasionally inspect how the results look like.
I actually have two problems/questions:
show: true
the electron window on demand -- would you guys be fine if I added a cosmiconfig that would make it possible?show: false
but I haven't verified this theory yet. Did you guys have any experience with it?Thanks!