tape-testing / tape

tap-producing test harness for node and browsers
MIT License
5.77k stars 307 forks source link

Shorter `NODE_TAPE_OBJECT_PRINT_DEPTH` env variable #534

Closed wooorm closed 3 years ago

wooorm commented 3 years ago

A very useful feature for me is NODE_TAPE_OBJECT_PRINT_DEPTH, because I work with a lot of large JSON objects, added in https://github.com/substack/tape/issues/418. and #420. However, it’s a rather long name. I find myself reading the docs, CMD+F for depth, and copy pasting that line a lot because I can’t seem to remember it.

Would it be of interest to add a shorter alias for that flag? Perhaps NODE_TAPE_DEPTH or TAPE_DEPTH or so? I can make the PR.

ljharb commented 3 years ago

env vars have a high chance of conflicting, so it’s usually best if they’re long.

While this feedback may have been helpful when it was added, I’m pretty sure it’s not worth the complexity of having two env vars for the same thing - which one wins? What if they’re different? etc.

wooorm commented 3 years ago

Yeah, understandable. And alt idea that solves my use case is to have a different flag that presents more as “expand/inspect all”. I don‘t really care about what number the depth it set to, just that it’s very large. That still has the problem of how the two different variables work together though. Say, NODE_TAPE_DEEP, which when set is equivalent to 100 or so. NODE_TAPE_OBJECT_PRINT_DEPTH precedes over it. And opts.objectPrintDepth precedes over that.

ljharb commented 3 years ago

The env var is meant as a universal shortcut, that shouldn’t need to be typed often - the thing expected for common use is the depth option on each inspect call.

wooorm commented 3 years ago

The normal behavior of tape is great. I want the normal size to be small. Just, sometimes, I need to inspect a deep and complex case. Where I can either dive into the code and add a console.dir(actual, {depth: null}) / {objectPrintDepth: 100}, but using an env variable to just print it all feels cleaner to me.

In any case, my usage seems to be an edge case so I’ll close this.