From 61330b2f849c1b2dc829b93dac283b9bc086c1a4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 9 Feb 2019 20:57:36 -0800 Subject: [PATCH] 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 Reviewed-By: Anto Aravinth --- .../test-assert-position-indicator.js | 18 ++++++++++++++++++ .../test-assert-position-indicator.out | 0 2 files changed, 18 insertions(+) create mode 100644 test/pseudo-tty/test-assert-position-indicator.js create mode 100644 test/pseudo-tty/test-assert-position-indicator.out diff --git a/test/pseudo-tty/test-assert-position-indicator.js b/test/pseudo-tty/test-assert-position-indicator.js new file mode 100644 index 00000000000000..26f82b5b13fb1b --- /dev/null +++ b/test/pseudo-tty/test-assert-position-indicator.js @@ -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('^') +); diff --git a/test/pseudo-tty/test-assert-position-indicator.out b/test/pseudo-tty/test-assert-position-indicator.out new file mode 100644 index 00000000000000..e69de29bb2d1d6