Reputation: 119
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
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);
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);
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);
Upvotes: 1
Views: 160
Reputation: 766
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.
Upvotes: 3