Yuvaraja KS
Yuvaraja KS

Reputation: 151

Replacing of TestCafe async / await with promises

For some reasons, I am trying to replace TestCafe Async / Await with Promises. Below is the chunk of code where I used the promises in place of await.

But getting an error like: 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.enter image description here

Upvotes: 3

Views: 1363

Answers (1)

Andrey Belym
Andrey Belym

Reputation: 2903

If you don't want to use async/await, you can return a Promise from the test function:

fixture `Example`
    .page `example.com`;

test(`example`, t => {
   let promise = Promise.resolve(t);

   return promise
       .then(result => {
           return result.typeText('...');
       })
       .then(result => {
           return result.click('...');
       });
});

Upvotes: 4

Related Questions