Skip to content

feat(jest-snapshot): expose snapshot paths in failure details - #16374

Open
ahnpnl wants to merge 1 commit into
jestjs:mainfrom
ahnpnl:feat/5034-snapshot-path
Open

feat(jest-snapshot): expose snapshot paths in failure details#16374
ahnpnl wants to merge 1 commit into
jestjs:mainfrom
ahnpnl:feat/5034-snapshot-path

Conversation

@ahnpnl

@ahnpnl ahnpnl commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Custom reporters can already access snapshot actual and expected values through failureDetails. This change also exposes resolved external snapshot file paths as matcherResult.snapshotPath, enabling reporters to locate or open the failing .snap file.

Inline snapshot failures omit snapshotPath because their source location is the test file, not an external snapshot file.

Fixes #5034

Test plan

  • yarn build:js
  • yarn build:ts
  • yarn jest packages/jest-snapshot/src/__tests__/State.test.ts packages/jest-snapshot/src/__tests__/matcher.test.ts
  • yarn jest e2e/__tests__/failureDetailsProperty.test.ts
  • JEST_JASMINE=1 yarn jest e2e/__tests__/failureDetailsProperty.test.ts
  • yarn typecheck:tests
  • yarn check-changelog
  • yarn check-copyright-headers

@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9090a36
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6a86891b1e4950000834cdca
😎 Deploy Preview https://deploy-preview-16374--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the require-changelog If a PR does requires a changelog entry label Aug 19, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@16374

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@16374

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@16374

create-jest

npm i https://pkg.pr.new/create-jest@16374

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@16374

expect

npm i https://pkg.pr.new/expect@16374

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@16374

jest

npm i https://pkg.pr.new/jest@16374

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@16374

jest-circus

npm i https://pkg.pr.new/jest-circus@16374

jest-cli

npm i https://pkg.pr.new/jest-cli@16374

jest-config

npm i https://pkg.pr.new/jest-config@16374

@jest/console

npm i https://pkg.pr.new/@jest/console@16374

@jest/core

npm i https://pkg.pr.new/@jest/core@16374

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@16374

jest-diff

npm i https://pkg.pr.new/jest-diff@16374

jest-docblock

npm i https://pkg.pr.new/jest-docblock@16374

jest-each

npm i https://pkg.pr.new/jest-each@16374

@jest/environment

npm i https://pkg.pr.new/@jest/environment@16374

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@16374

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@16374

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@16374

@jest/expect

npm i https://pkg.pr.new/@jest/expect@16374

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@16374

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@16374

@jest/globals

npm i https://pkg.pr.new/@jest/globals@16374

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@16374

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@16374

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@16374

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@16374

jest-message-util

npm i https://pkg.pr.new/jest-message-util@16374

jest-mock

npm i https://pkg.pr.new/jest-mock@16374

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@16374

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@16374

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@16374

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@16374

jest-resolve

npm i https://pkg.pr.new/jest-resolve@16374

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@16374

jest-runner

npm i https://pkg.pr.new/jest-runner@16374

jest-runtime

npm i https://pkg.pr.new/jest-runtime@16374

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@16374

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@16374

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@16374

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@16374

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@16374

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@16374

@jest/transform

npm i https://pkg.pr.new/@jest/transform@16374

@jest/types

npm i https://pkg.pr.new/@jest/types@16374

jest-util

npm i https://pkg.pr.new/jest-util@16374

jest-validate

npm i https://pkg.pr.new/jest-validate@16374

jest-watcher

npm i https://pkg.pr.new/jest-watcher@16374

jest-worker

npm i https://pkg.pr.new/jest-worker@16374

pretty-format

npm i https://pkg.pr.new/pretty-format@16374

commit: 9090a36

@ahnpnl
ahnpnl force-pushed the feat/5034-snapshot-path branch 2 times, most recently from df3c054 to b7c8112 Compare August 20, 2026 03:56
@ahnpnl ahnpnl changed the title feat: expose snapshot paths in failure details feat(jest-snapshot): expose snapshot paths in failure details Aug 20, 2026
@ahnpnl
ahnpnl marked this pull request as ready for review August 20, 2026 04:20
Copilot AI lite review requested due to automatic review settings August 20, 2026 04:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends jest-snapshot failure details by including the resolved external snapshot file path on snapshot matcher failures (matcherResult.snapshotPath), enabling custom reporters to locate the relevant .snap file. Inline snapshot failures intentionally omit snapshotPath, since their source location is the test file.

Changes:

  • Add optional snapshotPath to SnapshotState.match() results for failing external snapshots (including test.failing “pure matching” runs).
  • Plumb snapshotPath through toMatchSnapshot’s returned matcherResult so it surfaces in failureDetails.
  • Add unit/e2e coverage and update the changelog entry.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/jest-snapshot/src/State.ts Adds optional snapshotPath to match results for failing external snapshots.
packages/jest-snapshot/src/index.ts Includes snapshotPath on the exported matcher result when present.
packages/jest-snapshot/src/tests/State.test.ts Adds unit tests covering when snapshotPath is present/omitted.
packages/jest-snapshot/src/tests/matcher.test.ts Updates matcher test to assert snapshotPath is propagated.
e2e/failureDetails-property/tests/tests.test.js Adds an external snapshot failure case in the e2e fixture.
e2e/failureDetails-property/tests/snapshots/tests.test.js.snap Adds the external snapshot file used to force a snapshot mismatch.
e2e/tests/failureDetailsProperty.test.ts Normalizes absolute snapshot paths in output and updates inline snapshots accordingly.
CHANGELOG.md Adds a feature entry documenting the new snapshotPath exposure.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md Outdated
@ahnpnl
ahnpnl force-pushed the feat/5034-snapshot-path branch from b7c8112 to 9090a36 Compare August 20, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

require-changelog If a PR does requires a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to access snapshot comparison details

2 participants