From 9bc78d4d82e9367fb0e04545a479838f6bccf2e2 Mon Sep 17 00:00:00 2001 From: Prudhvi Date: Wed, 28 Dec 2022 17:27:44 +0530 Subject: [PATCH 1/3] Added a check for 0 ms in pause command --- lib/api/client-commands/pause.js | 2 +- test/src/api/commands/client/testPause.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/api/client-commands/pause.js b/lib/api/client-commands/pause.js index 08c112f603..9468b145c9 100644 --- a/lib/api/client-commands/pause.js +++ b/lib/api/client-commands/pause.js @@ -42,7 +42,7 @@ Pause.prototype.command = function(ms, cb) { // If we don't pass the milliseconds, the client will // be suspended indefinitely, until the user presses some // key in the terminal to resume it. - if (!ms) { + if (!ms && ms !== 0) { // eslint-disable-next-line console.log(`Paused... Press or F10 to step over to the next test command and pause again. diff --git a/test/src/api/commands/client/testPause.js b/test/src/api/commands/client/testPause.js index f9620a28f5..b04e1609f6 100644 --- a/test/src/api/commands/client/testPause.js +++ b/test/src/api/commands/client/testPause.js @@ -20,6 +20,16 @@ describe('.pause()', function() { this.client.start(done); }); + it('browser.pause(0) pauses atleast 0ms and not more than 2000ms', function(done) { + const startTime = new Date(); + this.client.api.pause(0, function() { + const timeElapsed = new Date() - startTime; + assert.ok(timeElapsed >= 0); + }); + + this.client.start(done); + }); + it('browser.pause(200) pauses for atleast 200ms and not more than 2000ms', function(done) { const startTime = new Date(); this.client.api.pause(200, function() { From 163ed522704e95bc1a0f8a941d974af286a199f5 Mon Sep 17 00:00:00 2001 From: Prudhvi Date: Wed, 28 Dec 2022 23:51:46 +0530 Subject: [PATCH 2/3] fix test --- test/src/api/commands/client/testPause.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/api/commands/client/testPause.js b/test/src/api/commands/client/testPause.js index b04e1609f6..b543b158b5 100644 --- a/test/src/api/commands/client/testPause.js +++ b/test/src/api/commands/client/testPause.js @@ -20,7 +20,7 @@ describe('.pause()', function() { this.client.start(done); }); - it('browser.pause(0) pauses atleast 0ms and not more than 2000ms', function(done) { + it('browser.pause(0) does not pause more than 2000ms', function(done) { const startTime = new Date(); this.client.api.pause(0, function() { const timeElapsed = new Date() - startTime; From 3a74c82a773d68635f0018228e64a8d18ab1c93e Mon Sep 17 00:00:00 2001 From: Prudhvi Date: Wed, 4 Jan 2023 12:28:21 +0530 Subject: [PATCH 3/3] Added check for undefined --- lib/api/client-commands/pause.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/client-commands/pause.js b/lib/api/client-commands/pause.js index 9468b145c9..6accd2dadc 100644 --- a/lib/api/client-commands/pause.js +++ b/lib/api/client-commands/pause.js @@ -42,7 +42,7 @@ Pause.prototype.command = function(ms, cb) { // If we don't pass the milliseconds, the client will // be suspended indefinitely, until the user presses some // key in the terminal to resume it. - if (!ms && ms !== 0) { + if (ms === undefined) { // eslint-disable-next-line console.log(`Paused... Press or F10 to step over to the next test command and pause again.