From 8d9d083d2cdc110bccc84536f66c4d941768a57b 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. --- .../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