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
There's a .id property on both requests & responses which will match, and you can use that to join up the two. This is also available on requests and responses from events e.g. via server.on('response', (res) => ...), which will fire for all messages, not just for this one specific rule.
That said, I'm open to adding a 2nd req parameter to beforeResponse too if that would be useful, PRs welcome.
This will be mildly tricky in some places but not super difficult - just remember to handle the remote-client case too for both serialization & deserialization. It's easy to check that's working properly by including a test in remote-client.spec.ts, most of those tests run in node (so fast & easy) but uses a remote client like a browser to cover the serialization/deserialization code. I'd suggest just copying this test, changing the contents of beforeRequest and beforeResponse to check that the expected parameters are all there and serialized properly, and then checking you get a 200 at the end (i.e. no assertion errors in the callbacks). Does that make sense?
I'm not quite sure how to connect response with its request?
Say I'd like to be able to do:
Maybe it's worth adding
req
as the second argument ofbeforeResponse()
? Then it would be possible to do like:The text was updated successfully, but these errors were encountered: