Skip to content

Reject conflicting Fantom inline snapshot updates before writing source - #60593

Draft
GianSandoval5 wants to merge 1 commit into
react:mainfrom
GianSandoval5:fix/fantom-conflicting-inline-snapshots-60591
Draft

GianSandoval5 wants to merge 1 commit into
react:mainfrom
GianSandoval5:fix/fantom-conflicting-inline-snapshots-60591

Conversation

@GianSandoval5

Copy link
Copy Markdown

Summary:

When multiple tests reach one inline snapshot call with different values, Fantom's source writer silently keeps the last value. The initial run can pass while modifying the file to fit only one test; the next run then fails, and updating snapshots can alternate the saved value.

Validate all pending values before rewriting the source and reject conflicting values for the same line. Keep coalescing identical values, since Fantom combines pending updates across configurations. This deliberately preserves that existing behavior rather than adopting Jest's rejection of every repeated call.

Fixes #60591.

The existing line-based locator is unchanged; this does not add support for multiple inline snapshot calls on one source line. Only the Node-side writer and its Jest tests change.

Changelog:

[INTERNAL] [FIXED] - Fantom: reject conflicting inline snapshot updates before modifying test source.

Test Plan:

Base: 27acce22615ee0682eb018826a000240da90c2d9. Ubuntu 22.04, Node 24.22.3, Yarn 1.22.22.

Five new test cases cover conflicts during creation and update with the whole file unchanged, identical values across configurations, and distinct calls including a multiline snapshot.

  • With unchanged production source and the new tests, the targeted suite has exactly 2 failures and 9 passes (exit 1); both failures are the new conflicting-value cases.
  • With this change, yarn jest private/react-native-fantom --runInBand --ci: 196 passed, 0 failed, 0 skipped, 16 suites, exit 0.
  • yarn prettier --check on both changed files: exit 0.
  • yarn eslint --max-warnings 0 on both changed files: exit 0.
  • yarn flow-check --max-workers 2 --json: exit 0 for both baseline production source and patched source.
  • Sources remain clean after validation.
  • Evidence and exact commands: https://github.com/GianSandoval5/react-native/actions/runs/47521162112 . The functional Fantom subtree 439b0c3d23046a4b689ee68af6de7f4438e9102c is identical to the tested commit; verification files stay on a separate fork branch.
  • The initial CI run failed only formatting of a new assertion; it was formatted with the repository's Prettier 3.10.0 and all checks were rerun.

Not run: the author's full Metro/Hermes/native Fantom reproducer, Android/iOS builds, RNTester, the entire monorepo Jest suite or repository-wide ESLint. This validates the actual Node source writer and Fantom's regular Jest suites, not native platforms or end-to-end Fantom execution.

AI-assisted preparation, kept as a draft for Gian's personal review and end-to-end follow-up. No CLA has been signed on the contributor's behalf; Meta CLA eligibility must be resolved before merge.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Fantom: a toMatchInlineSnapshot() call that several tests reach is written with one of their values, where Jest refuses it

1 participant