Integration Testing an iOS App with a local node.js server

I’m just starting out with CircleCI and am looking for some direction.

I have UI Integration Tests for an iOS application that utilize a local node.js instance of our backend API and a local mysql server. The iOS UI tests communicate with the local server through localhost. With CircleCI, is it possible to have an instance of a node.js server and a mysql server running concurrently with XCode tests in a macos executor and able to communicate?

Hi there,

Welcome to our community!

What you are trying to accomplish is certainly possible, the only challenge is that the base MacOS image does not come with MySQL pre-installed. (Although it does have node[1]).

You can install MySQL with homebrew brew install mysql, but this will add some time to each build. If you can get away with using SQLite instead of MySQL you might be better off.

[1] https://circle-macos-docs.s3.amazonaws.com/image-manifest/build-520/index.html

I don’t know what Docker is like on Mac OS, but perhaps pulling a minimal MySQL image might be worth a try. It works flawlessly for a colleague of mine on the desktop, but I don’t know how well that translates to a CI environment.

I think that would add to the overall time even more because macOS doesn’t come with docker by defautl.

Sorry for this being slightly off topic but in general I would not recommend spinning up a local instance of your backend for testing unless you have a really well structured way of easily spinning up an environment, for instance using docker. It is definitely possible but from my experience it will be a pain to maintain down the road when both the app and the backend grows in complexity and thus not worth it in the end.

Instead I recommend using a simple mock server to mock the API responses of your backend. This can be done only by adding some dependencies to your iOS app when running tests.

You can get some inspiration here:

On top of that if you wanna look into making a contract between what the app expects and what the API provides I recommend looking at Pact. You can make the app create a contract for the various endpoints that it depends on and have the backend verify that it fulfils this contract. https://docs.pact.io

3 Likes

Thanks for this guidance @petergp, I was attempting to answer the question that was posed, but you took it a step further and showed us the right way™ to do this. :slight_smile:

1 Like

Did you end up going with the contract approach as opposed to the full integration testing approach? I’m investigating integration testing and was disappointed to find that I couldn’t use Docker to set up my service from a macos executor (or at least it isn’t officially supported). Indeed, maintaining all the steps to install our service on a mac might be tedious (although they are the same steps we have for local development, so might be needed anyway).