fix(jest-circus): preserve Error.cause in JSON failureMessages (#15949)#15967
Open
xamgore wants to merge 3 commits intojestjs:mainfrom
Open
fix(jest-circus): preserve Error.cause in JSON failureMessages (#15949)#15967xamgore wants to merge 3 commits intojestjs:mainfrom
xamgore wants to merge 3 commits intojestjs:mainfrom
Conversation
…s#15949) Add recursive cause serialization to circus failureMessages and cover it in e2e JSON output assertions.
✅ 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: |
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.
Preserve
Error.causein JSONfailureMessagesfor bothjest-circusandjest-jasmine2.Summary
Fixes #15949.
The CLI already showed error causes, but JSON results could drop them in
assertionResults[*].failureMessages.The gap was in runner-level serialization:
jest-circusbuilt failure messages fromerror.stack/error.messagejest-jasmine2reporter did the same forfailedExpectationsNode stacks do not include the full cause chain, so nested causes were missing in JSON output.
This PR updates both runners to serialize causes recursively with a
[cause]: ...marker, including:ErrorcausesChanges:
packages/jest-circus/src/utils.tspackages/jest-jasmine2/src/reporter.tsTests:
e2e/__tests__/failures.test.tschecks both:[cause]: Error: error during g[cause]: here is the causepackages/jest-jasmine2/src/__tests__/reporter.test.tsTest plan
Ran:
yarn eslint e2e/__tests__/failures.test.ts packages/jest-circus/src/utils.ts packages/jest-jasmine2/src/reporter.ts packages/jest-jasmine2/src/__tests__/reporter.test.tsyarn jest e2e/__tests__/failures.test.ts -t "includes error causes in JSON failureMessages" --runInBandJEST_JASMINE=1 yarn jest e2e/__tests__/failures.test.ts -t "includes error causes in JSON failureMessages" --runInBandyarn jest packages/jest-circus/src/__tests__/utils.test.ts --runInBandyarn jest packages/jest-jasmine2/src/__tests__/reporter.test.ts --runInBand