Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 231
Yuvaraja KS Avatar asked Jun 04 '26 18:06

Yuvaraja KS


1 Answers

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('...');
       });
});

like image 167
Andrey Belym Avatar answered Jun 07 '26 07:06

Andrey Belym



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!