Add toMatchInlineSnapshot support#55892
Closed
andrewdacenko wants to merge 1 commit intofacebook:mainfrom
Closed
Conversation
|
@andrewdacenko has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95077617. |
andrewdacenko
added a commit
to andrewdacenko/react-native
that referenced
this pull request
Mar 3, 2026
Summary: Pull Request resolved: facebook#55892 Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
8d175a4 to
3148ded
Compare
andrewdacenko
added a commit
to andrewdacenko/react-native
that referenced
this pull request
Mar 3, 2026
Summary: Pull Request resolved: facebook#55892 Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
39aaab6 to
0c22230
Compare
andrewdacenko
added a commit
to andrewdacenko/react-native
that referenced
this pull request
Mar 4, 2026
Summary: Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
andrewdacenko
added a commit
to andrewdacenko/react-native
that referenced
this pull request
Mar 4, 2026
Summary: Pull Request resolved: facebook#55892 Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
0c22230 to
6b3f579
Compare
andrewdacenko
added a commit
to andrewdacenko/react-native
that referenced
this pull request
Mar 4, 2026
Summary: Pull Request resolved: facebook#55892 Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
6b3f579 to
ad4745a
Compare
Summary: Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation, matching Jest's inline snapshot behavior. On first run, snapshot values are written directly into the test source file as template literal arguments. On subsequent runs, values are compared and the test fails on mismatch unless the `-u` flag is passed to force an update. The implementation spans the two-process Fantom architecture: **Runtime (Hermes VM):** - `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares received values against existing inline snapshots, captures stack traces for new/mismatched snapshots, and tracks results per test. - `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class that serializes values with `prettyFormat` and delegates to snapshot context. - `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`. **Runner (Node.js):** - `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack traces back to original source locations via source map symbolication. New `saveInlineSnapshotsToSource` directly rewrites the test source file by finding each `toMatchInlineSnapshot(...)` call and replacing its argument with the formatted template literal. This avoids jest-snapshot's `saveInlineSnapshots` which requires Babel and Prettier 2.x. - `runner.js`: Generates source maps when inline snapshots need updating, collects pending snapshots across test configs, and writes them after all configs complete. Changelog: [Internal] Differential Revision: D95077617
ad4745a to
cfbee22
Compare
Collaborator
|
This pull request was successfully merged by @andrewdacenko in 43278f9 When will my fix make it into a release? | How to file a pick request? |
|
This pull request has been merged in 43278f9. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Adds
toMatchInlineSnapshot()to the Fantom customexpectimplementation,matching Jest's inline snapshot behavior. On first run, snapshot values are
written directly into the test source file as template literal arguments.
On subsequent runs, values are compared and the test fails on mismatch
unless the
-uflag is passed to force an update.The implementation spans the two-process Fantom architecture:
Runtime (Hermes VM):
snapshotContext.js: NewtoMatchInlineSnapshotmethod that comparesreceived values against existing inline snapshots, captures stack traces
for new/mismatched snapshots, and tracks results per test.
expect.js: NewtoMatchInlineSnapshotmethod on theExpectclassthat serializes values with
prettyFormatand delegates to snapshot context.setup.js: PlumbsinlineSnapshotResultsthroughTestCaseResult.Runner (Node.js):
snapshotUtils.js: NewprocessInlineSnapshotResultsresolves VM stacktraces back to original source locations via source map symbolication.
New
saveInlineSnapshotsToSourcedirectly rewrites the test source fileby finding each
toMatchInlineSnapshot(...)call and replacing itsargument with the formatted template literal. This avoids jest-snapshot's
saveInlineSnapshotswhich requires Babel and Prettier 2.x.runner.js: Generates source maps when inline snapshots need updating,collects pending snapshots across test configs, and writes them after
all configs complete.
Changelog: [Internal]
Differential Revision: D95077617