-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Conversation
* fixes jestjs#10176 * repeats behaviour of the node.js Console class https://github.com/nodejs/node/blob/9918bdf5cb07f58d230522244a372cbb1b510956/lib/internal/console/constructor.js
There was a problem hiding this 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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 :) |
@jeysal then I'll close this PR. |
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. |
Summary
Fixes #10176. Now
console.dir
repeats the behavior of the Node.js Console class.Test plan