1

compare 1 with 2 & 1 with 3, can click edit when I exclude await from expect or when I do await t.expect with await

1.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit) //  ***----- doesn't clicks and throws error***  
       .expect(await DetailsPage.addCommentWindow.value).eql(comData.comment);

2.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit)  // **----- does click and no error**
       .expect(DetailsPage.addCommentWindow.value).eql(comData.comment);

3.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit);  // **----- does click and no error**

await t.expect(await DetailsPage.addCommentWindow.value).eql(comData.comment);
Community
  • 1
  • 1
chris
  • 119
  • 1
  • 6

1 Answers1

3

Option 2 is the right one. You should never use await in expect. TestCafe awaits selector promises and does it at the right moment of the time and during the specified timeout. Option 1 doesn't work because you forced the DetailsPage.addCommentWindow.value evaluation before DetailsPage.edit is clicked.

Alexey Lindberg
  • 756
  • 3
  • 12