Search code examples
promisewebdriver-io

WebdriverIO waitUntil example is not working


I am trying to use Webdriverio v5 and I have problems to run the example for waitUntil https://webdriver.io/docs/api/browser/waitUntil.html

it('should wait until text has changed', () => {
    browser.waitUntil(() => {
      return $('#someText').getText() === 'I am now different'
    }, 5000, 'expected text to be different after 5s');
});

the error is saying

Type 'boolean' is not assignable to type 'Promise<boolean>'

anyone else is facing the same problem?

or how to fix it?

while in v4 everything works as expected


Solution

  • It looks like you're using typescript in your tests. Make sure you've gone through the entire typescript/webdriverio setup: https://webdriver.io/docs/typescript.html

    In this case, I think you need to add wdio-sync to your compilerOptions types setting.

    "compilerOptions": {
        "types": ["node", "@wdio/sync"]
    }