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

fix(expect): resolve message on assertion errors #10989

Merged
merged 1 commit into from
Dec 30, 2020

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Dec 30, 2020

Summary

When the error is thrown from expect, there's not reason to keep the message property a function. A function is removed by JSON.stringify, so it's lost when transferred between workers. And the structured clone used by worker_threads throws as the message function references out of scope variables.

Extracted from #10981.

Test plan

Test tweaked

@@ -293,7 +293,7 @@ const makeThrowingMatcher = (
// Passing the result of the matcher with the error so that a custom
// reporter could access the actual and expected objects of the result
// for example in order to display a custom visual diff
error.matcherResult = result;
error.matcherResult = {...result, message};
Copy link
Member Author

Choose a reason for hiding this comment

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

message is resolved to a string on line 275

@SimenB SimenB merged commit c2f152d into jestjs:master Dec 30, 2020
@SimenB SimenB deleted the resolve-jest-assertion-message branch December 30, 2020 16:12
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants