I'm using webdriverIO with typescript and jest to automate react application. I have a simple test to check how long it takes for a particular element to display on the screen. There's a process which runs on clicking a button and once the process is completed, a popup is displayed on the screen.
I'm printing time before I wait for the element and then printing it after. Below is the code:
$("//button[@testid='btn-submit']").click();
const time1 = Date.now();
console.log("Time started --- " + time1);
$(".messagedialog").waitForExist(600000);
const time2 = Date.now();
console.log("Time Ended --- " + time2);
$("//span[text()='View Result']").click();
When it runs, it prints the line "Time Ended --" right after "Time Started -- ", even though the application is still waiting for the message dialog. I'm running webdriverIO in the sync mode using @wdio/sync.
Why the "Time Ended" line is getting printed even though previous statement ".waitForExist()" has not returned true yet?