From 02c44a48943302d07a3b9575402a8992e57dada8 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 24 Sep 2018 10:15:52 +0200 Subject: assert: reduce diff noise Assertion errors that produce a diff show a diff for identical entries in case one side of the comparison has more object properties than the other one. Those lines are now taken into account and will not show up as diverging lines anymore. Refs: https://github.com/nodejs/node/issues/22763 PR-URL: https://github.com/nodejs/node/pull/23048 Refs: https://github.com/nodejs/node/issues/22763 Reviewed-By: Anna Henningsen Reviewed-By: Shingo Inoue Reviewed-By: James M Snell --- test/parallel/test-assert-deep.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 306e8367d4..3a5fca74d4 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -65,9 +65,13 @@ assert.deepEqual(arr, buf); () => assert.deepStrictEqual(buf2, buf), { code: 'ERR_ASSERTION', - message: `${defaultMsgStartFull}\n\n` + - ' Buffer [Uint8Array] [\n 120,\n 121,\n 122,\n' + - '+ 10,\n+ prop: 1\n- 10\n ]' + message: `${defaultMsgStartFull} ... Lines skipped\n\n` + + ' Buffer [Uint8Array] [\n' + + ' 120,\n' + + '...\n' + + ' 10,\n' + + '+ prop: 1\n' + + ' ]' } ); assert.deepEqual(buf2, buf); @@ -80,9 +84,13 @@ assert.deepEqual(arr, buf); () => assert.deepStrictEqual(arr, arr2), { code: 'ERR_ASSERTION', - message: `${defaultMsgStartFull}\n\n` + - ' Uint8Array [\n 120,\n 121,\n 122,\n' + - '+ 10\n- 10,\n- prop: 5\n ]' + message: `${defaultMsgStartFull} ... Lines skipped\n\n` + + ' Uint8Array [\n' + + ' 120,\n' + + '...\n' + + ' 10,\n' + + '- prop: 5\n' + + ' ]' } ); assert.deepEqual(arr, arr2); @@ -822,7 +830,7 @@ assert.throws( code: 'ERR_ASSERTION', name: 'AssertionError [ERR_ASSERTION]', message: `${defaultMsgStartFull}\n\n ` + - '{\n+ a: 4\n- a: 4,\n- b: true\n }' + '{\n a: 4,\n- b: true\n }' }); assert.throws( () => assert.deepStrictEqual(['a'], { 0: 'a' }), @@ -891,7 +899,7 @@ assert.deepStrictEqual(obj1, obj2); assert.throws( () => assert.deepStrictEqual(arrProxy, [1, 2, 3]), { message: `${defaultMsgStartFull}\n\n` + - ' [\n 1,\n+ 2\n- 2,\n- 3\n ]' } + ' [\n 1,\n 2,\n- 3\n ]' } ); util.inspect.defaultOptions = tmp; -- cgit v1.2.1