Skip to content

Commit 1d3d633

Browse files
PM8668zinserjan
authored andcommitted
Fix viewport-size. (#23)
1 parent 82f4137 commit 1d3d633

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/modules/mapViewports.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ export async function mapWidths(browser, delay, widths = [], iteratee) {
22
const results = [];
33

44
if (!widths.length) {
5-
const { width } = await browser.windowHandleSize();
5+
const {width} = await browser.getViewportSize();
66
const result = await iteratee(width);
77
results.push(result);
88
} else {
99
for (let width of widths) {
10-
await browser.windowHandleSize({width, height: 1000});
10+
await browser.setViewportSize({width, height: 1000});
1111
await browser.pause(delay);
1212
const result = await iteratee(width);
1313
results.push(result);

test/wdio/VisualRegressionLauncher.test.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,20 @@ describe('VisualRegressionLauncher - custom compare method & hooks', function ()
220220

221221
beforeEach(function () {
222222
spy(browser, 'pause');
223-
spy(browser, 'windowHandleSize');
223+
spy(browser, 'setViewportSize');
224224
});
225225

226226
afterEach(function () {
227227
browser.pause.restore();
228-
browser.windowHandleSize.restore();
228+
browser.setViewportSize.restore();
229229
});
230230

231231
it('uses a custom delay passed in constructor options', async function () {
232232
await browser.checkViewport({
233233
widths: [500],
234234
});
235235

236-
assert.isTrue(browser.pause.calledAfter(browser.windowHandleSize), 'browser.pause should have been after windowHandleSize');
236+
assert.isTrue(browser.pause.calledAfter(browser.setViewportSize), 'browser.pause should have been after setViewportSize');
237237
assert.isTrue(browser.pause.calledWith(250), 'browser.pause should have been called called with 250');
238238
});
239239

@@ -243,27 +243,27 @@ describe('VisualRegressionLauncher - custom compare method & hooks', function ()
243243
viewportChangePause: 1500,
244244
});
245245

246-
assert.isTrue(browser.pause.calledAfter(this.beforeScreenshotStub), 'browser.pause should have been called after windowHandleSize');
246+
assert.isTrue(browser.pause.calledAfter(browser.setViewportSize), 'browser.pause should have been called after setViewportSize');
247247
assert.isTrue(browser.pause.calledWith(1500), 'browser.pause should have been called with 1500');
248248
});
249249
});
250250

251251
context('widths', function () {
252252

253253
beforeEach(function () {
254-
spy(browser, 'windowHandleSize');
254+
spy(browser, 'setViewportSize');
255255
});
256256

257257
afterEach(function () {
258-
browser.windowHandleSize.restore();
258+
browser.setViewportSize.restore();
259259
});
260260

261261
it('uses width passed in constructor options', async function () {
262262
const expectedWidth = browser.options.visualRegression.widths[0];
263263
await browser.checkViewport();
264264

265-
const { width } = browser.windowHandleSize.args[0][0];
266-
assert.strictEqual(width, expectedWidth, 'browser.windowHandleSize should have been called with global value');
265+
const { width } = browser.setViewportSize.args[0][0];
266+
assert.strictEqual(width, expectedWidth, 'browser.setViewportSize should have been called with global value');
267267
});
268268

269269
it('uses a custom width passed in command options', async function () {
@@ -273,8 +273,8 @@ describe('VisualRegressionLauncher - custom compare method & hooks', function ()
273273
widths: [expectedWidth],
274274
});
275275

276-
const { width } = browser.windowHandleSize.args[0][0];
277-
assert.strictEqual(width, expectedWidth, 'browser.windowHandleSize should have been called with custom value');
276+
const { width } = browser.setViewportSize.args[0][0];
277+
assert.strictEqual(width, expectedWidth, 'browser.setViewportSize should have been called with custom value');
278278
});
279279
});
280280

0 commit comments

Comments
 (0)