Debug proxy record requests/responses and mock sequence

Viewed 190

I need to record sequence of api calls and then stub this sequense again.

For example my scripts going via this proxy to test.com and get response "1" - proxy recording request GET test.com and response "1", then I switching proxy to stub mode with this sequence and when my script call again test.com it getting response from stub.

I not need stub exact url, just queue of responses, if second response will return "2", then queue will be "1","2" and when twice calling test.com I must get 1 and 2 as recorded.

Maybe someone know tools which can do this? I know about charles proxy - but it seems can't do this. Sure it can remote map etc.. but I don't want always manually editing responses.

1 Answers

@rst360, at Feather Finance we use Cypress to debug and subsequently automate tests in these kinds of situations.

By default, Cypress will request GET from test.com, but you can save the response from test.com in a fixture file (in Cypress a network stub is called a fixture). Then you can use Cypress's intercept() function to specify which given calls to test.com should be intercepted and responded with a stub.

Here are a few threads on how to use Cypress to stub network responses:

If what you are looking for is a tool to cache your own server's responses, I would suggest using Redis. This article tells you how to do it.

Related