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
But this doesn't work, since yahoo.com becomes the last request after the first wait().
We probably need two methods, one for resolving already queued requests at the time wait() is invoked, and one for waiting until all moxios requests (including ones triggered in moxios promise handlers) are finished - maybe named moxios.waitAll()?
I'm no guru of testing frameworks, but this behavior seems desirable and typical since it gives developers much more control over what requests actually get initiated, and lets them inspect the application state at every step of the process rather than only at the very end.
The text was updated successfully, but these errors were encountered:
scottmas
changed the title
Make wait only clear resolve currently queued requests
Make wait only resolve currently queued requests
Sep 16, 2016
mostRecent() is a convenience for accessing the last request. In your case yahoo.com would be the most recent as it was requested last. In cases where you have multiple requests, as you described, you can also access the requests by index: moxios.requests.at(0) would be google.com in your example and moxios.requests.at(1) would be yahoo.com.
This is accurate, but I don't think it should be that way. Here's how I think of it:
The script gets executed. axios.get('https://www.google.com') gets added to the queue of pending promises.
The queue is cleared by some mechanism (possibly moxios.wait()) and the promise is resolved and removed from the queue.
As it gets removed, the handlers attached to it are invoked, causing the request to yahoo to trigger, thus adding another promise to the recently cleared queue.
The queue is flushed again by another call to moxios.wait() and finally the last promise gets resolved.
The setTimeout implementation of wait() causes requests that get queued as a result of a prior axios requests to ALSO be fulfilled.
Consider the following script which gets executed.
Our test file looks like so:
But this doesn't work, since yahoo.com becomes the last request after the first wait().
We probably need two methods, one for resolving already queued requests at the time wait() is invoked, and one for waiting until all moxios requests (including ones triggered in moxios promise handlers) are finished - maybe named moxios.waitAll()?
I'm no guru of testing frameworks, but this behavior seems desirable and typical since it gives developers much more control over what requests actually get initiated, and lets them inspect the application state at every step of the process rather than only at the very end.
The text was updated successfully, but these errors were encountered: