Skip to content

Commit ac83d19

Browse files
TrottMylesBorins
authored andcommitted
test: confirm that assert truncates long values
`assert` has code to truncate values that take more than 128 characters to display. Add a test for this functionality, as the code is not currently exercised in the existing tests. PR-URL: #8134 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 06a1c9b commit ac83d19

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/parallel/test-assert.js

+5
Original file line numberDiff line numberDiff line change
@@ -526,4 +526,9 @@ testBlockTypeError(assert.doesNotThrow, undefined);
526526
assert.throws(() => { throw 'error'; }, (err) => err === 'error');
527527
assert.throws(() => { throw new Error(); }, (err) => err instanceof Error);
528528

529+
// Long values should be truncated for display.
530+
assert.throws(() => {
531+
assert.strictEqual('A'.repeat(1000), '');
532+
}, new RegExp(`^AssertionError: '${'A'.repeat(127)} === ''$`));
533+
529534
console.log('All OK');

0 commit comments

Comments
 (0)