Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports returned values on received function not throw when expect .toThrow() #15541

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chenesan
Copy link
Contributor

@chenesan chenesan commented Mar 14, 2025

Summary

Implement #15525, to reports returned value of received function when that function call not throw with .toThrow() / .toThrowErrorMatchingSnapshot().

To check the format, see the test case in e2e/__tests__/toThrowErrorMatchingSnapshot.test.ts .

Changed Scope

  • expect: in toThrowMatchers.ts for each toThrowExpectedClass/Message/Regex function, pass received and returnedValueOnNotThrow to compose the error message.
  • jest-snapshot: do the same thing but for toThrowErrorMatchingSnapshot.

Test plan

  • Updated the snapshot of unit test in toThrowMatchers.test.ts to make sure it contained returned value message
  • Add test case for toThrowErrorMatchingSnapshot.test.ts e2e case to ensure it can report the stringified returned object values, not [Object Object].

Copy link

linux-foundation-easycla bot commented Mar 14, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Mar 14, 2025

Deploy Preview for jestjs failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 5b8943a
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/67d3d46b2cdf79000826c0b3

@chenesan chenesan force-pushed the feat/report_returned_values_on_to_throw branch 2 times, most recently from 4a6fcc9 to 34488b0 Compare March 14, 2025 05:34
@chenesan chenesan force-pushed the feat/report_returned_values_on_to_throw branch from 34488b0 to 5b8943a Compare March 14, 2025 07:02
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.

1 participant