You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nodeunit has great feature in expect, but ending asynchronous tests is often painful, mainly in tests with more than 1 callback. I think, it has easy solution and implementation isn't hard.
Instread of passing raw callback, pass returned callback from test.callback([expect 1,] callback);.
Invoking test.callback will store given callback and mark him as done after expected number of calls (internal mechanism will watch status of each callback). Each call will invoke original callback. If all test.callback are marked as done, test.done is called automatically.
It should handle all cases, even callback in callback.
Nodeunit has great feature in expect, but ending asynchronous tests is often painful, mainly in tests with more than 1 callback. I think, it has easy solution and implementation isn't hard.
Instread of passing raw callback, pass returned callback from
test.callback([expect 1,] callback);
.Invoking
test.callback
will store given callback and mark him as done after expected number of calls (internal mechanism will watch status of each callback). Each call will invoke original callback. If all test.callback are marked as done, test.done is called automatically.It should handle all cases, even callback in callback.
It doesn't break existing code, it is optional.
Implementation could look like this:
The text was updated successfully, but these errors were encountered: