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

Exploit the second console.dir argument #10182

Closed
wants to merge 1 commit into from

Conversation

xamgore
Copy link
Contributor

@xamgore xamgore commented Jun 20, 2020

Summary

Fixes #10176. Now console.dir repeats the behavior of the Node.js Console class.

Test plan

beforeafter

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks! Could you update the changelog as well?

const deepObject = {1: {2: {3: {4: {5: {6: 'value'}}}}}};
_console.dir(deepObject, {depth: 6});

expect(_stdout).toMatch('value');
Copy link
Member

Choose a reason for hiding this comment

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

maybe this should be a snapshot so we can see the entire structure? same for the test below

Copy link
Contributor Author

@xamgore xamgore Jun 23, 2020

Choose a reason for hiding this comment

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

util.inspect implementation may differ from version to version as described in node.js documentation, but if that's ok for you, I'll introduce expect(deepObject).toMatchInlineSnapshot().

Copy link
Member

Choose a reason for hiding this comment

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

Jest's output in this case shouldn't vary though, should it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you, please, rephrase the sentence? Not sure I properly understand you.

util.format may also differ from version to version, thus Jest's console.log output may vary from version to version. Same with console.dir.

Will Node.js core developers decide to change util.inspect for deep objects? Who knows, maybe they will add/remove extra spaces between colons. But value will always be in the output.

I'm not a core developer, so just say what to do, I'll do it.

@jeysal
Copy link
Contributor

jeysal commented Oct 15, 2020

I'm sorry this was forgot about :/ - #10638 was just opened and is up to date on master. You're still a commit author in there for when that is merged :)

@xamgore
Copy link
Contributor Author

xamgore commented Oct 15, 2020

@jeysal then I'll close this PR.

@xamgore xamgore closed this Oct 15, 2020
@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 11, 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.

console.dir doesn't respect depth option
4 participants