From 8a21d2a7389346884bc4c5de2cff8e7c565dfd6a Mon Sep 17 00:00:00 2001 From: Travis Meisenheimer Date: Wed, 18 Jan 2017 20:57:12 -0600 Subject: [PATCH] test: add message verification on assert.throws MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add regular expression for error message validation to instances of assert.throws() in test-assert.js. PR-URL: https://github.com/nodejs/node/pull/10890 Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig --- test/parallel/test-assert.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 563f67e91e07a8..6eddd9534958a9 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -92,11 +92,16 @@ assert.doesNotThrow(makeBlock(a.deepEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im)); +assert.throws(makeBlock(a.deepEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepEqual \/a\/im$/); { const re1 = /a/g;