Browse Source

test: add message verification on assert.throws

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 <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6.x
Travis Meisenheimer 8 years ago
committed by Myles Borins
parent
commit
ca53866333
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 15
      test/parallel/test-assert.js

15
test/parallel/test-assert.js

@ -90,11 +90,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;

Loading…
Cancel
Save