Search code examples
javascriptfunctional-testingfuncunit

Javascript FuncUnit open a wider window?


When I try to use FuncUnit to open a browser window to run some tests, the window it opens is too narrow and the site I am testing hides some menu items to work with the narrow window. Is there some way to increase the width of the window FuncUnit opens so the presence of these menu items can be tested? The docs provide no help with this issue.

The FuncUnit code I have is really basic:

test("dummy test", function () {
F.open('http://localhost:8000/');
});

I can increase the size of the window by hand after the test starts running, but that does not work for automated testing.

EDIT:

  • I dug through the FuncUnit source code and found that it is setting the popup window width to half the browser width. Changing this fixed the issue.

Other attempts that worked less well:

  • I was able to test the page in an iframe, which resolves the width issue. All the F('#something') calls then require an extra parameter, so F('#something', 0). Every. Damn. Time.
  • Attempted to disable Bootstrap's responsive features. It requires extensive changes, but they are detailed here
  • Found a plugin for Chrome that forces popups into a new tab, fixing the width issue. It is called The One. The test is not able to communicate with the new tab.

Solution

  • In the callback of F.open() use F.win.resizeTo(width, height):

    F.open("desired-url", function onOpenSuccess() {
        F.win.resizeTo(1024, 768);
    });