-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advice regarding indeterminate callbacks #1964
Comments
@natzcam I don't know the answer except using Btw, if you could split this logic into 2 tests it would be easier to track/manipulate from the first sight. |
You could also count how many None of this helps if a callback is invoked twice though. (I'm closing this issue for housekeeping purposes, but let's keep the conversation going.) |
You could also count how many None of this helps if a callback is invoked twice though. (I'm closing this issue for housekeeping purposes, but let's keep the conversation going.) |
You could also use import test from 'ava';
import pEvent from 'p-event';
test('2 callbacks', async t => {
const alice = new Alice();
await pEvent(alice, 'connect');
const bob = new Bob();
await pEvent(bob, 'connect');
t.pass();
}); |
Tried above, but the test would not complete because connection is initiated on the constructor and
Using Promise.all would solve it though, but it would circle back to my original question. :)
It would be nice, for callbacks, there is a 'countdown' functionality. Wherein, the test would end when the countdown = 0
|
I think that's functionality one could add atop of AVA once #1692 lands. |
How best to approach this?
There is no guarantee which connect callback will be called first, but I need to assert that both got called. Promise.all could solve this but are there any alternatives?
The text was updated successfully, but these errors were encountered: