Hi, is there a way to mock external api that app c...
# help
n
Hi, is there a way to mock external api that app calls with standalone using JSON ?
i
Yes, but you would need to manipulate your host file to point to the IP address of the server you're running the standalone WireMock. On Windows that would be through the hosts file.
n
not sure how is it possible to do it when you deploy app to cloud, but is there a way to do it with json request and response ?
i
You mean running your app in the cloud and then have it from there be mocked?
You can run WireMock in a container and have it configured using JSON config file. You challenge will be to have the endpoint route to your WireMock instance
n
I mean mock the external api that app calls with json request response
i
Yes, deploy WireMock as a container and route your request to that container. You could do that by deploying a DNS and manipulate that. Easier would be if you can use change the endpoint in your application directly, do your testing and change to the real thing when you're done. But I would probably go for using a custom DNS that will route the endpoint, say api.extservice.com to your container's IP address. When all is working fine, you can change it back to the real IP
1
On both Windows and Linux you can change the hosts file, which is the easiest way to handle this
You can also configure your WireMock as a proxy to the real endpoint for those requests you don't have a mock response for, just make sure that WireMock uses a different DNS or else things will go in circles 😉