r/reactnative • • 15d ago

How are you testing the gap between your API and your app??

We renamed a field in a Go response structure last week, JSON tag stayed the same so every test on our side passed but the app was reading an old field from a cached response and showing users stale data for 3 days, both sides looked fine in isolation though and neither side owned the test that would’ve caught it.

Our backend is Go with chi and sqlc and postgres and the testing there is solid, httptest for handlers, testcontainers for DB, stripe mock for webhooks. Our detox tests mock the API so they wouldn’t have caught it either and nobody is testing for when a real user signs up in the app and the API creates the account and the webhook fires and the app shows the right state.

is this always the backend team’s problem? and if you do run full flows does that reside in the same CI or separate ?? because our test suite takes too long

0 Upvotes

18 comments sorted by

1

u/deepyawn 15d ago

e2e tests on a git hook for finalized things runs on the Dev's machines and don't write test cases untill the things are completed and tested and finalized by manual QA tester and still make it ready to ship. And once things are completed on dev(internal test release) branch we take 7-10 days to baseline performance stats and bottlenecks while we review review each and everyline and then write the e2e cases(we don't run all the test cases we have a selected few files which we run and then we decide if this test cases always need to run with git hook or we when we explicily want to do a full 100% test of the application. If things are working fine under load and all things pass. We do the release. Our whole e2e suite takes 1h12m to 1h52m depending on the dev's machine but we do have 96% coverage. Honestly we just run it once week and it's overkill for us but in this age of ai I'm just happy that I can let juniors take over and I just do pr check and once in a while when I am lazy and run the suite so visual watch everything happens while I eat something.

1

u/WallabyWinter4027 14d ago

1.5 hours for a test suite is wild! But having that 96% coverage as a weekly safety net makes a lot of sense. We’re trying to keep our feedback loop tighter for everyday PRs, so running it on every commit isn't feasible for us right now. I do like the idea of pushing the heavy e2e runs to a weekly cadence or only running them before a major release though.

1

u/Huge_Pool7424 15d ago

7-10 days of bake is solid, i'd still pin a contract fixture so the api side can't quietly break the decoder in between

1

u/deepyawn 15d ago

Yes we have done that but we have some v1 vs v2 apis and users still using the old application, we don't wanna make them force update because we have a new UI launch at v2 so all the things get added for new features via feature flags and we will push it for all users once we are user thing are working for via these features flags and its going on track so far by Feb we are hoping for full migration. It's all financial data or legal tender data that why taking this much time and effort.

2

u/Huge_Pool7424 14d ago

for the old app versions i'd keep a response fixture per api version in ci, so v1 can't drift quietly. a min supported version flag lets you nudge people to update without forcing it

1

u/Sirecuit 15d ago

Hi, just curious about what you use to write and run those E2E tests (Argent, Maestro, other) and what size your app is in terms of tested screens/actions. I'm the maintainer of a fully featured music streaming/player app and just testing the strict bare minimum already takes hours with Maestro. Obviously I'm a solo dev so it's different but the effort it takes me to write proper tests that don't fail because Android or iOS decided to open a random native modal dialog during the tests and the hours a run takes to complete puts me off of using this tool more.

1

u/DistributionDull1347 15d ago

I'd treat that boundary as shared ownership: pin the response contract (OpenAPI/Pact or a checked-in response fixture) and have the RN app test its real decoder/cache path against it, including a stale cached payload followed by refresh. Then keep one signup-to-webhook-to-fetch-state smoke flow in CI, while the broad Detox suite can run nightly or before release. That catches app/API drift without making every PR wait for the whole suite.

1

u/WallabyWinter4027 14d ago

I really like this take. Pinning the contract and testing the cache/refresh path against it feels like exactly what we're missing. Doing just one critical smoke flow in CI and pushing the full Detox suite to nightly is a great compromise to keep PRs moving. Are you using a specific tool like Pact for the contract testing, or just checking in raw JSON fixtures?

1

u/anthony-ball 15d ago

The stale cache part is what I'd fix first, because no test suite was going to catch that reliably. I parse every response through a zod schema in the API client layer and put a version in the cache key, so when the shape changes the old cached data gets thrown away instead of rendered. Parse failures also get reported as errors in production, which tells you within an hour that the backend changed something instead of days later. On ownership, whoever changes the response shape owns updating the shared schema, and backend CI checks real responses against it so the break shows up on their PR.

1

u/WallabyWinter4027 14d ago

Putting a version in the cache key combined with Zod parsing is brilliant. That would have literally saved us here. Since our backend is Go, how do you handle sharing that schema? Do you auto-generate the Zod schemas from Go structs/OpenAPI, or just maintain them manually on the frontend? Getting those parse failures in prod immediately instead of 3 days later sounds like a dream.

1

u/kenlawlpt 15d ago

Stale cache is a bit of an edge case. I just solved an issue like this which was reported a year ago, and I had no idea why users were being served the stale cache (until I asked AI and it found it in minutes).

You just learn to force fetch/refresh the cache when certain things happen, or based on whatever your app logic is.

1

u/WallabyWinter4027 14d ago

Cache invalidation strikes again, right? 😅 It really is one of those things that hides in the background until it completely breaks a critical user flow. We definitely need to get more aggressive with our force refreshes or cache busting when the data shape changes.

1

u/NoBullfrog11 14d ago

we hit this seam in an expo app too, detox tests with a mocked api gave us confidence in screens but not in signup and profile creation actually lining up. the most useful middle ground was one short smoke flow against a staging backend after deploy, create a test account, assert the returned profile shape and key state, then clean it up. it caught integration drift without making every commit wait on a full device suite, and keeping teh fixture versioned made failures easier to pin down.

1

u/WallabyWinter4027 14d ago edited 11d ago

Glad we aren't the only ones hitting this with Expo and Detox. We ended up doing exactly this, one signup to webhook to profile flow against staging after every deploy, running on a real app build instead of mocked screens. Ours runs on Autosana so nobody has to remember. Do you run yours against a persistent staging env or spin one up per run?

1

u/syedaalishan 13d ago

On your fixtures-vs-Pact question, I'd start with a few checked-in JSON responses and test them through the app's actual decoder and cache code. Don't automatically regenerate those fixtures whenever the backend changes, or both sides can agree on the same mistake. Include an old cached payload followed by a fresh response. Pact becomes more useful when independently released consumers need to state different compatibility requirements.

1

u/HeroSMS 11d ago

+1 to the shared fixture. One thing on the 3 days: if the cache is persisted (React Query persister, redux-persist, AsyncStorage), old entries need busting, not just the server fix.

  • React Query's persistQueryClient has a buster option. Bump it and old persisted caches get thrown away.
  • redux-persist has version + migrate for the same job.
  • Or put an API/schema version in the cache key.

Also check maxAge on whatever you persist. React Query's default is 24h, so 3 days would point to a longer setting or another cache layer.

Agree with keeping one smoke flow per PR and the rest nightly. Simple ownership rule on top, since you asked whose problem it is: whoever changes the contract updates the fixture in the same PR, and backend CI fails if they don't.