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
letreqWaiter={resolve: null,promise: null,settled: async()=>{awaitreqWaiter.promise;awaitsettled();},};letid=0;functionrequestWaiter(){id++;letself=id;console.log('creating waiter',self);reqWaiter.resolve?.();reqWaiter.promise=newPromise((resolve)=>{reqWaiter.resolve=()=>{console.log('Resolving id',self);resolve();waitForPromise(newPromise((finish)=>{requestAnimationFrame(()=>{console.log('clearing promise and resolve',self);reqWaiter.promise=null;reqWaiter.resolve=null;finish();});}),);};});}
And usage:
// in some async handlerreqWaiter.resolve?.();// in your test actionsrequestWaiter()// or reqWaiter.create();// do actions which trigger async behaviorawaitreqWaiter.settled();
Why?
sometimes you need to wait outside of the waiter system
(maybe test-helpers use the settled state, and you need something to assure your mocked / passed callback holds up test execution before continuing)
The text was updated successfully, but these errors were encountered:
Example code:
And usage:
Why?
sometimes you need to wait outside of the waiter system
(maybe test-helpers use the settled state, and you need something to assure your mocked / passed callback holds up test execution before continuing)
The text was updated successfully, but these errors were encountered: