I was in the same situation recently. Not Algolia, but something else. I ended up writing tests that run against a sandboxed version of the external API. I thought about mocking the external API responses (I.e. saving the JSON response to a file and just using that from then in), but decided against it as there were just so many unknowns about integrating with the external API that I felt I had to actually connect to it to check that my code does what it’s supposed to. I guess when my own code is stable I could revert to mocking it, but in the process of learning how the external API works I thought this was a good approach.
Writing a mock api for Algolia testing (ideas and feedback needed)
I am writing a bunch of tests to gain more confidence in my codebase. The tests work fine, but as part of the app there is a call that is made with Scout to Algolia and it returns some geobased results. After searching I haven't found a good way to test this behavior, so I was thinking about mocking up the API results from Algolia and then testing against that instead.
My concern is that potentially this will be very brittle, and I am unsure of whether or not it will actually serve my purpose or not.
Does anyone have any experience doing this or something similar? I am not looking for a solution, just some good ideas/advice I guess, my own solution would be to write a class with some different methods depending on what query parameters are sent with the "request".
Thanks in advance!
Please or to participate in this conversation.