ember-test-helpers
ember-test-helpers copied to clipboard
Add support for waitUntil accepting an async function?
Hi,
I wanted to use waitUntil and pass an async function as the callback.
It looks like this isn't currently supported. Is this something you would be interested in supporting?
If so I can try to open a PR which implements Promise support in waitUntil.
@makepanic I'm not sure what would be the point of accepting an async function. If you have a function that returns a promise you can just do await myFunction(), no need for waitUntil
I primarily needed the repeated truthy checks of waitUntil.
await waitUntil(async () =>
await someAsyncTruthynessCheck());
where someAsyncTruthynessCheck is an async function that return true after a while/couple executions.
Definitely would be great to be able to:
await waitUntil(async () => {
await findAll('.class-element').length === 2;
});
Any updates on this?
Hmm, @tpetrone that doesn't seem quite right. findAll does not return a promise (see API docs here), that use case should already be handled without changes to support async functions.
Thanks for clarifying @rwjblue. I did had misunderstood findAll's response. In this case I don't have a particular use case for async callback support inside waitUntil.
FWIW, I'm not opposed to adding support for waitUntil to handle async functions. If someone wants to pick that up, we can try to work out the details in a PR...