Add possibility to enqueue/append requests with server.use instead of only being able to append #1176
MartinJaskullaAccenture
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Hey, @MartinJaskullaAccenture. Looks like you're looking for res.once(). Once a handler uses a mocked response composed via |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is how I would like to write my unit tests (I wrapped
server.use
in themockOnce
utility function):By reading this I would assume that
clickAddToBasket
triggers 2 api calls in the order they appear in the test. However the first api call would returnmyMockData2
, becausemsw
essentially uses a stack instead of a queue.It would be nice if server.use would accept options, which allow me to enqueue/append my requests instead of appending them (In theory I would like to enqueue the
server.use
calls, but keep the original handlers passed tosetupServer
last in the queue).If this is not feasible, then the feature request Get currently registered handlers would also help with my use case. Then it would be easy to get the current handlers in
mockOnce
where I could do my custom enqueueing.Beta Was this translation helpful? Give feedback.
All reactions