Is there a way to pretty print whole objects? (overcoming Js.log shortcoming)

Hi There,

When using Js.log to pretty print an object in Jest tests, I get the following output:

      { value: 1, more: undefined },
      { value: 2, more: [ [Object], [Object] ] }

(objects are shown up to 1 level of nesting).

Is there a way to print the whole nested object?

1 Like

Would Js.Json.stringifyAny work for you?


For something that formats a bit more nicely, you could use Js.Json.stringifyWithSpace, but that requires your object has a Js.Json.t type.


If you’re running on NodeJS, one alternative is to invoke the following once in an entry point:

const util = require('util');
// enable full object reproting in console.log
util.inspect.defaultOptions.depth = null;

This will disable the [Object] shortenings at all levels.