Last active
October 21, 2017 07:01
-
-
Save jochakovsky/65cea6612f210705d470224a4da2a718 to your computer and use it in GitHub Desktop.
WebdriverIO browser.waitUntil proposal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
const RESOLVE_TIME = 50; | |
const TIMEOUT = 200; | |
describe('webdriver.io page', function() { | |
it('waitUntil should stop waiting when promise resolves truthy', function () { | |
const start = Date.now(); | |
browser.waitUntil(new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(true); | |
}, RESOLVE_TIME); | |
}), TIMEOUT); | |
const end = Date.now(); | |
assert(end - start >= RESOLVE_TIME && end - start < TIMEOUT); | |
}); | |
it('waitUntil should stop waiting when promise resolves falsey', function () { | |
const start = Date.now(); | |
browser.waitUntil(new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(false); | |
}, RESOLVE_TIME); | |
}), TIMEOUT); | |
const end = Date.now(); | |
assert(end - start >= RESOLVE_TIME && end - start < TIMEOUT); | |
}); | |
it('waitUntil should stop waiting when promise rejects truthy', function () { | |
const start = Date.now(); | |
browser.waitUntil(new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(true); | |
}, RESOLVE_TIME); | |
}), TIMEOUT); | |
const end = Date.now(); | |
assert(end - start >= RESOLVE_TIME && end - start < TIMEOUT); | |
}); | |
it('waitUntil should stop waiting when promise rejects falsey', function () { | |
const start = Date.now(); | |
browser.waitUntil(new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(false); | |
}, RESOLVE_TIME); | |
}), TIMEOUT); | |
const end = Date.now(); | |
assert(end - start >= RESOLVE_TIME && end - start < TIMEOUT); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current results: