stateful-mock-http-proxy
v0.0.4
Published
Mocks json responses from API or other mocks for testing purposes.
Readme
Stateful mock http proxy
The goal of this small express app is to mock json responses from API or other mocks in testing environments.
TLDR
1 - Run the proxy providing the url of the API to mock
Using docker :
docker run -it -p 3000:3000 -e TARGET=http://whatever.api sportrizer/stateful-mock-http-proxyUsing nodejs :
export TARGET=http://whatever.api && npm run starthttp://whatever.api will be proxified to http://localhost:3000/api
2 - Add a mock to be consumed in the next api call
curl --request POST \
--url http://localhost:3000/mock \
--header 'Content-Type: application/json' \
--data '{
"url": "/resource",
"method": "GET",
"json" : {
"my-custom": "response"
}
}'3 - future calls to the api will be mocked
curl --request GET \
--url http://localhost:3000/api/resourceresults in : {"my-custom": "response"} only one time (headers and status code are followed).
