0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00

test: add assert test for position indicator

This test adds coverage for a ternary in assertion_error.js that checks
if stderr is a TTY.

PR-URL: https://github.com/nodejs/node/pull/26024
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This commit is contained in:
Rich Trott 2019-02-09 20:57:36 -08:00
parent 82c4e170e5
commit 40a8a73916
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
'use strict';
require('../common');
const assert = require('assert');
process.env.NODE_DISABLE_COLORS = true;
process.stderr.columns = 20;
// Confirm that there is no position indicator.
assert.throws(
() => { assert.deepStrictEqual('a'.repeat(30), 'a'.repeat(31)); },
(err) => !err.message.includes('^')
);
// Confirm that there is a position indicator.
assert.throws(
() => { assert.deepStrictEqual('aaa', 'aaaa'); },
(err) => err.message.includes('^')
);