M
M
magary42021-05-04 14:54:09
JavaScript
magary4, 2021-05-04 14:54:09

Jest console output losing color?

file contents

console.log({a: 1, b:2});
      console.table({a: 1, b:2});


for some reason the result of 6091357ed801e748754248.png
console.table is converted to console.log but it is displayed in color, but the first command outputs a string instead of a colorized object,

how to fix it so that you can see the dump of the object in a formatted and colored form?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-05-04
@magary4

Because Jest is on the drum. Fix like this:

console.log(util.formatWithOptions({ colors: true }, '%O', { a: 1, b: 2 }));

util module .

A
Andrew, 2021-05-04
@f3d0t

console.dir({a: 1, b:2})

upd: still like this you can
console.dirxml({a: 1, b:2})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question