Skip to content

Commit 4b6ed24

Browse files
Trottevanlucas
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 <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5bc3119 commit 4b6ed24

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/parallel/test-assert.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,9 @@ testBlockTypeError(assert.doesNotThrow, undefined);
528528
assert.throws(() => { throw 'error'; }, (err) => err === 'error');
529529
assert.throws(() => { throw new Error(); }, (err) => err instanceof Error);
530530

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

0 commit comments

Comments
 (0)