facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

Change window resizes to test responsiveness #48

Open mririgoyen opened 5 years ago

mririgoyen commented 5 years ago

We would like to be able to change the window size in a test to determine if code handling responsiveness is functioning correctly.

Doing simple window.resizeTo(...) calls does not update the window.innerWidth.

Tying into the Electron remote seems to make it a bit further, but still does not trigger anything. For example:

const currentWindow = require('electron').remote.getCurrentWindow();
currentWindow.setSize(1400, 1000);
console.log(currentWindow.getSize()); // Shows 1400!
console.log(window.innerWidth); // Still is 800

In either case, the resize window eventListener is never called.

Is this possible currently or is there a known defect that disallows this from happening? The draw of using Electron for these types of tests is to use browser APIs, such as this.