pactum icon indicating copy to clipboard operation
pactum copied to clipboard

addDataFuncHandler should accept asynchronous function bodies

Open tnypxl opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. It's annoying that I can't use asynchronous functions in Data Function handlers

Describe the solution you'd like I invision something like:

pactum.handler.addAsyncDataFuncHandler('MyDataFunction', async () => {
  const result = await someAsyncFunction(10);
  return result;
})

or

Refactor existing method to accept a boolean whose default value is false. But when set to true will pass the function to an async version of the handler instead (I don't love this approach).

pactum.handler.addDataFuncHandler('MyDataFunction', async () => {
  const result = await someAsyncFunction(10);
  return result;
}, true)

tnypxl avatar Apr 12 '22 21:04 tnypxl

@tnypxl thank you for the suggestion. I don't think we need an independent function to handle asynchronous tasks. We need to enhance the existing function to support both of them without any additional params.

ASaiAnudeep avatar Apr 13 '22 17:04 ASaiAnudeep

Any workaround for this?

tzmgit avatar Jan 31 '23 18:01 tzmgit