resize(options)

🚧

This is a TDK feature

This is not supported in Testim's visual editor

This method resizes the browser window to the given x,y size coordinates.

  • options {object}
    • width {number} window width
    • height {number} the window height
  • returns: Promise that fulfills when the window has been resized

Note: the browser size is limited by what the browser, computer and grid can actually resize to. You can't for example resize a browser to 10px by 10px or 100000px by 10000px.

For example:

// ✅ resize to 1024/768
await resize({
  width: 1024,
  height: 768
});
// ✅ resize to 1280/1024
await resize({
  width: 1280,
  height: 1024
});
// ❌ this method resizes the whole browser window and not an element
await resize('body', {
  width: 1280,
  height: 1024
});
// ❌ it's over 9000! (so too big of a page)
await resize('body', {
  width: 9001,
  height: 9001
});

Full example:

'use strict';

const expect = require('chai').expect;
const { go, it, describe, getCookie, setCookie, evaluate } = require('testim');

describe('cookies', () => {
   
  test("resize", async () => {
      await go('http://jsbin.testim.io/quh/1');
      const oldWidth = await evaluate(() => document.body.getClientRects()[0].width);
      await resize({ width: 550, height: 550}); // 500 is the minimum size of Chrome
      const newWidth = await evaluate(() => document.body.getClientRects()[0].width);
      expect(oldWidth).to.not.equal(newWidth);
  });
  
});