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

Inline values in error messages #257

Merged
merged 2 commits into from
Dec 1, 2019
Merged

Inline values in error messages #257

merged 2 commits into from
Dec 1, 2019

Conversation

kevin940726
Copy link
Contributor

Fix #253.

Inline the values in the error messages to fix that some environment won't properly display string substitutions. By using , to separate each value, we can remain native formatter in each environment (node.js or all major browsers devtool). Since the value we want to log here might be non-serializable, converting them to strings often loose context and make the developer confused.

I also rewrite the tests to better represent how it's actually seen in the logs, so that we can guard it when something like this issue ever occurred in the future. A caveat here is that by doing so, our tests might only be able to run in node v10+.

@netlify
Copy link

netlify bot commented Nov 16, 2019

Deploy preview for redux-starter-kit-docs ready!

Built with commit 4cdaf35

https://deploy-preview-257--redux-starter-kit-docs.netlify.com

expect(value).toBe(type)
expect(action).toBe(dispatchedAction)
expect(log).toMatchInlineSnapshot(`
"A non-serializable value was detected in an action, in the path: \`type\`. Value: Symbol(SOME_CONSTANT)
Copy link
Collaborator

@markerikson markerikson Nov 16, 2019

Choose a reason for hiding this comment

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

Are the backslashes actually needed here? They should be escape characters and thus not appear in the actual output string, I would think.

Copy link
Contributor Author

@kevin940726 kevin940726 Nov 18, 2019

Choose a reason for hiding this comment

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

It’s auto generated by Jest via toMatchInlineSnapshot. Also, there is a backslash in the line above, so I think it’s needed.

@markerikson markerikson merged commit a3226cd into reduxjs:master Dec 1, 2019
@kevin940726 kevin940726 deleted the fix-error-message branch December 2, 2019 00:12
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.

Error messages appear to use placeholders
2 participants