protractor Understanding the Control Flow


Example

Consider the following test:

it('should test something', function() {
  browser.get('/dashboard/');

  $("#myid").click();
  expect(element(by.model('username')).getText()).toEqual('Test');

  console.log("HERE");
});

In the following test, when the console.log() is executed and you see HERE on the console, none of the Protractor commands from previous lines have been executed. This is an entirely asynchronous behavior. The commands are represented as promises and were put on the Control Flow which would execute and resolve the promises sequentially, one by one.

See more at Promises and the Control Flow.