Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a check for 0 ms in pause command #3534

Merged
merged 3 commits into from Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/api/client-commands/pause.js
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it if (ms === undefined) { instead? Because that's only when we should pause indefinitely (if the first argument is undefined). If something else is passed as the first argument which is falsy (null, false for ex.), then we should just let it go to the else clause and let setTimeout through an error, instead of pausing indefinitely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Will make changes.

// eslint-disable-next-line
console.log(`Paused...
Press <space> or F10 to step over to the next test command and pause again.
Expand Down
10 changes: 10 additions & 0 deletions test/src/api/commands/client/testPause.js
Expand Up @@ -20,6 +20,16 @@ describe('.pause()', function() {
this.client.start(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;
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() {
Expand Down