← Blog

The AI says fixed: what do the React Native save tests prove?

3 min read
Watch the walkthrough on YouTube

“The task is done” is a status message. To review a change, we need a command, an observed result and a clear account of the behavior that result covers.

The previous lesson introduced a retained save gate. Its tests exercise pure TypeScript logic; they do not establish that a React Native screen behaves correctly on a device.

Keep the first request pending under test control

The overlap check uses a deferred promise. Its resolution belongs to the test, so it can make the second call while the first is definitely pending:

const runSave = createSaveGate();
const request = deferred();
let calls = 0;

const first = runSave(() => {
  calls += 1;
  return request.promise;
});
const second = runSave(async () => {
  calls += 1;
});
const callsWhilePending = calls;

request.resolve();
const [firstResult, secondResult] = await Promise.all([first, second]);
assert.equal(callsWhilePending, 1);
assert.equal(firstResult, 'saved');
assert.equal(secondResult, 'ignored');

The full test file contains deferred and the required imports. The observation is how many task callbacks started before release. A guessed delay or a real network connection would add unrelated timing uncertainty.

Run the intentional failure first

From tutorial-series/sample/, use:

SHIP_NATIVE_GATE_FIXTURE=./save-gate.before.ts \
  node --experimental-strip-types --test save-gate.test.mjs

The incomplete implementation starts every callback. The observed result is four passing checks and one failed overlap check with 2 !== 1. An unsuccessful exit is expected for this fixture.

That failure matters. If the overlap test passed on a version that admits every call, we would need to inspect whether it actually exercised the requirement. Do not weaken the assertion to make an intentionally incomplete fixture pass.

Run the corrected helper

node --experimental-strip-types --test save-gate.test.mjs

The supplied corrected implementation passes all five checks:

Check Observation
Overlapping calls Only the first callback starts
Success A later call can save
Rejection The original error reaches the caller and retry works
Synchronous throw The flag is released
Separate owners One gate does not block another

These results were rerun during production preparation on Node 22.23.0. Test runtime is not a performance measurement of the app.

Node's TypeScript documentation distinguishes execution through type stripping from type checking. This command runs the helper's supported syntax; it does not typecheck the illustrative TSX component.

Report the boundary with the result

A supported report says:

The retained gate passed the supplied overlap and recovery checks. The caller was reviewed as source; native integration still needs host-app verification.

“The app can never send duplicate saves” is broader than the evidence. The tests do not cover every caller, another device, a lost response or server-side processing. A screen that creates a fresh gate on every press can remain broken while the helper tests pass.

In a host app, check loading feedback, repeated interaction, localized failures, retry and accessibility. Keep those results separate from the Node run. The sample component's unresolved project-component imports are intentional integration placeholders, not an installed app.

Exercise: tighten a completion report

Rewrite “all fixed and fully tested” into three statements: what command ran, which behavior it covered, and which checks remain. If you cannot name an actual run, label the conclusion as source review rather than execution evidence.

Next: package the repeated review into a skill.

The storyboard contains the complete spoken lesson. The video uses English AI-cloned owner narration with English and Arabic subtitles.

Comments

No account needed.

  1. Loading comments…