-
Notifications
You must be signed in to change notification settings - Fork 36
Closed
Labels
Description
Take a look at this test:
var webdriver = require('selenium-webdriver');
var common = require('./common.js');
let flowWrap = (promise: any) => {
return common.getFakeDriver().controlFlow().execute(() => {
return promise;
});
};
describe('mixed promises + control flow', function() {
let val: number;
it('should wait for it() to finish', function() {
val = 1;
return new Promise((resolve: Function) => {
resolve(webdriver.promise.fulfilled(7));
}).then((seven: any) => {
flowWrap(webdriver.promise.delayed(1000).then(() => {
val = seven;
}));
});
});
it('should have waited for setter in previous it()', function() {
expect(val).toBe(7);
});
});
This results in the error:
Expected 1 to be 7.
Meaning that the val = seven
line wasn't run (I have verified this in other ways too). You need all three of the following to make this bug happen:
- An ES6 promise (or possibly a
q
promise though I haven't tried) - A webdriver promise
controlFlow.execute()
synchronization
It's as though the combination of webdriver and ES6 promises just makes the control flow fall over.