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

console.dir doesn't respect depth option #10176

Closed
xamgore opened this issue Jun 18, 2020 · 4 comments · Fixed by #10638
Closed

console.dir doesn't respect depth option #10176

xamgore opened this issue Jun 18, 2020 · 4 comments · Fixed by #10638

Comments

@xamgore
Copy link
Contributor

xamgore commented Jun 18, 2020

According to the Node.js documentation, a depth option can be passed to console.dir:

Tells util.inspect() how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. To make it recurse indefinitely, pass null. Default: 2.

Imagine we run the code below. Jest 26.0.0 sequentially prints the arguments with depth 3 and ignores the depth option.

console.dir(deepObject, { depth: 5 })

There is a stack overflow discussion with a bug explanation. Briefly, maxDepth option is not passed to the prettyFormat function.

@SimenB
Copy link
Member

SimenB commented Jun 19, 2020

@xamgore
Copy link
Contributor Author

xamgore commented Jun 20, 2020

@SimenB yeah, I'd like to. Could you, please, explain where the "util" module is located?

  1. Replace the call of format function with formatWIthOptions, though it's been added in Node v10.0.0. What is ok, as Jest provides support only for Node ≥ 10.

  2. Replace the call with prettyFormat.

@SimenB
Copy link
Member

SimenB commented Jun 20, 2020

util is a node core module https://nodejs.org/api/util.html

@github-actions
Copy link

This issue 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 a pull request may close this issue.

3 participants