Search code examples
javascripttestingasync-awaitautomated-teststestcafe

Understanding order of execution in testcafe fixture


I am looking to better understand the order of execution within TestCafe fixture test when using await.

In the example below will action 1 always precede action2 and likewise will action2 precede action3 - i.e., is it guaranteed that both typeTexts will precede the click action?

class Page {
    ....
}

const page = new Page()

await t
  .typeText(page.login.email, 'emailaddress') //action 1
  .typeText(page.login.password, "password")  //action 2
  .click(page.login.submit)                   //action 3

In snippet below, am I correct that section 1 will be executed before section 2

await t //section 1
  .typeText(page.login.email, 'emailaddress') 
  .typeText(page.login.password, "password")
  .click(page.login.submit)

await t //section 2
  .typeText(page.login.something, 'bblah')
  .click(page.dosomething.submit)

Solution

  • You are correct; the execution is straightforward. In your first example, the third action will be not executed before the first two. In the second example, section #1 will be executed before section #2.