'A call to an async function is not awaited. Use the "await" keyword in Test Cafe

I'm getting this error:

A call to an async function is not awaited. Use the "await" keyword before actions, assertions or chains of them to ensure that they run in the right sequence.

But I am using an await within my code, what am I doing incorrectly?

test("Accepts the cookie", async t => {

    const interfaceSelect = Selector('#sp_message_iframe_617100');
    await
        t.switchToIframe('#sp_message_iframe_617100')
        t.click(Selector('button').withText('Accept'))
        t.switchToIframe('#select_region-select-module_select_30IZf')
        const countrySelect = Selector('#region-select-module_select__30lZf');
        t.click(Selector('button').withText('United Kingdom'))
});

Thanks,



Solution 1:[1]

The TestCafe's methods are chainable and return a Promise. You need to add an await before each method call or one await before the whole chain.

test("Accepts the cookie", async t => {

    const interfaceSelect = Selector('#sp_message_iframe_617100');

    await t.switchToIframe('#sp_message_iframe_617100');
    await t.click(Selector('button').withText('Accept'));
    await t.switchToIframe('#select_region-select-module_select_30IZf');

    const countrySelect = Selector('#region-select-module_select__30lZf');

    await t.click(Selector('button').withText('United Kingdom'));
});
test("Accepts the cookie", async t => {
    const interfaceSelect = Selector('#sp_message_iframe_617100');

    await t
        .switchToIframe('#sp_message_iframe_617100')
        .click(Selector('button').withText('Accept'))
        .switchToIframe('#select_region-select-module_select_30IZf');

    const countrySelect = Selector('#region-select-module_select__30lZf');

    await  t.click(Selector('button').withText('United Kingdom'));
});

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mlosev