Skip to content

ES6 Promises and webdriver promises/control flow don't play well together #59

@sjelin

Description

@sjelin

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:

  1. An ES6 promise (or possibly a q promise though I haven't tried)
  2. A webdriver promise
  3. controlFlow.execute() synchronization

It's as though the combination of webdriver and ES6 promises just makes the control flow fall over.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions