Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abilities for mocking the service data, so that the screens can be consistently tested for changes #158

Open
g-tiwari opened this issue Jun 20, 2023 · 1 comment

Comments

@g-tiwari
Copy link

Is there any capability exist to mock the backend test data and then load my page with that data. As of now for some of my screens the data is dynamic and React native owl end up showing that as bug for every test run.
Are we planning to add support to add mocking ?

@kevindice
Copy link

Hi @g-tiwari, I might recommend a metro config override where you could swap out a real module with a mocked one containing a data fixture.

For example:

This would be the real file myApi.ts

export const getProfile = () => fetch('https://myapi.com/me');

And this would be your mock myApi.e2emock.ts:

export Promise.resolved({ username: 'asdf' });

Your metro override would prioritize one file extension over another depending on whether an environment variable is set or not.

IMO, support for mocking like this should fall outside of the scope of Owl here, but there are definitely ways to achieve what you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants