From b8bdf0ebd7e9c5a623badc89a67a810dc82bf9ed Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 26 May 2019 13:09:07 -0400 Subject: [PATCH] console: fix table() output Fixes: https://github.com/nodejs/node/issues/27915 PR-URL: https://github.com/nodejs/node/pull/27917 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat --- lib/internal/console/constructor.js | 1 + test/parallel/test-console-table.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 9c262aef62be25..e3de39f8126b7c 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -412,6 +412,7 @@ const consoleMethods = { const opt = { depth, maxArrayLength: 3, + breakLength: Infinity, ...this[kGetInspectOptions](this._stdout) }; return inspect(v, opt); diff --git a/test/parallel/test-console-table.js b/test/parallel/test-console-table.js index 98c6dd8776fda2..eba7ba610c7393 100644 --- a/test/parallel/test-console-table.js +++ b/test/parallel/test-console-table.js @@ -244,3 +244,17 @@ test([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ` │ 1 │ 'Z' │ 2 │ └─────────┴─────┴─────┘ `); + +{ + const line = '─'.repeat(79); + const header = `${' '.repeat(37)}name${' '.repeat(40)}`; + const name = 'very long long long long long long long long long long long ' + + 'long long long long'; + test([{ name }], ` +┌─────────┬──${line}──┐ +│ (index) │ ${header}│ +├─────────┼──${line}──┤ +│ 0 │ '${name}' │ +└─────────┴──${line}──┘ +`); +}