What to use for mocking response for mobile native app

Hi all,

I would like kindly ask you about your advice on the following situation I am facing.
I work on an automation testing for mobile native application (web is not related).
This means that the automation is checking the UI of the application.
I am using Appium, WebDriverIO framework and Cucumber technologies.
For some of the testing scenarios I need to “fake” the response in order to see different UI on the screen.
I did some research and found out that I have to use mock server and mocked json files, which the app reads instead of the real endpoint responses.
However, I am not able to find an article with examples or GitHub repo, which will correctly show me how to create such mock server and such ,json files.
What I saw as tools are Reproxy, MockServer, GraphQL mock - but all of them shows just pieces of code, not the whole structure of a sample automation project.

I would appreciate any suggestion which tool is easy for usage and links to reliable resources.

I think you are talking about a mock api server. There are a bunch of them out there, and I don’t have direct experience but here is a fairly recent article comparing 7 of them. Maybe one works for you?

Thanks for the reply and the suggestion.
Maybe I am searching for some tool that could be somehow integrated in an environment with a TypeScript code. I can not use GUI tools separately from the automation workflow.

try https://github.com/nock/nock#readme

Thanks for the reply! It appears that Nock is easy tool for usage and implementation. However, I still can not display the mocked reply on the application screen. I assume the app is calling the backend API instead of the mocked response.
This is how my code looks like
let url = nock(‘https://xl5zni43ijehjl6pxmzb2yidpq.appsync-api.us-east-1.amazonaws.com’);
url.post(’/graphql’)
.replyWithFile(200, ‘modify_response.json’, {
‘Content-Type’: ‘application/json’,
})

Am I missing something? The data, which is in modify_response.json file is not displayed on the screen.

@Radostina_Gencheva please check my blog hope it will solve your problem to mock responses and check mobile app ui.

You can use https://github.com/AppiumTestDistribution/appium-interceptor-plugin with appium 2.0 to mock api responses for Native/Hybrid android apps. Its is lightweight and no dependency required from client side.

Hi Radostina! I faced with the same issue. did you get a handle on the problem?