feat(jest-snapshot): expose snapshot paths in failure details - #16374
feat(jest-snapshot): expose snapshot paths in failure details#16374ahnpnl wants to merge 1 commit into
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
babel-jest
babel-plugin-jest-hoist
babel-preset-jest
create-jest
@jest/diff-sequences
expect
@jest/expect-utils
jest
jest-changed-files
jest-circus
jest-cli
jest-config
@jest/console
@jest/core
@jest/create-cache-key-function
jest-diff
jest-docblock
jest-each
@jest/environment
jest-environment-jsdom
@jest/environment-jsdom-abstract
jest-environment-node
@jest/expect
@jest/fake-timers
@jest/get-type
@jest/globals
jest-haste-map
jest-jasmine2
jest-leak-detector
jest-matcher-utils
jest-message-util
jest-mock
@jest/pattern
jest-phabricator
jest-regex-util
@jest/reporters
jest-resolve
jest-resolve-dependencies
jest-runner
jest-runtime
@jest/schemas
jest-snapshot
@jest/snapshot-utils
@jest/source-map
@jest/test-result
@jest/test-sequencer
@jest/transform
@jest/types
jest-util
jest-validate
jest-watcher
jest-worker
pretty-format
commit: |
df3c054 to
b7c8112
Compare
There was a problem hiding this comment.
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
snapshotPathtoSnapshotState.match()results for failing external snapshots (includingtest.failing“pure matching” runs). - Plumb
snapshotPaththroughtoMatchSnapshot’s returnedmatcherResultso it surfaces infailureDetails. - 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.
b7c8112 to
9090a36
Compare
Summary
Custom reporters can already access snapshot
actualandexpectedvalues throughfailureDetails. This change also exposes resolved external snapshot file paths asmatcherResult.snapshotPath, enabling reporters to locate or open the failing.snapfile.Inline snapshot failures omit
snapshotPathbecause their source location is the test file, not an external snapshot file.Fixes #5034
Test plan
yarn build:jsyarn build:tsyarn jest packages/jest-snapshot/src/__tests__/State.test.ts packages/jest-snapshot/src/__tests__/matcher.test.tsyarn jest e2e/__tests__/failureDetailsProperty.test.tsJEST_JASMINE=1 yarn jest e2e/__tests__/failureDetailsProperty.test.tsyarn typecheck:testsyarn check-changelogyarn check-copyright-headers