From ae91ee202da6062e3eed397017e8eade2282cc57 Mon Sep 17 00:00:00 2001 From: Nihar Phansalkar Date: Sun, 24 Dec 2023 06:32:10 +0000 Subject: [PATCH] test: added test for assert.ok() change Added test to check the behaviour of the newly added isNativeError() function to assert.ok() --- test/parallel/test-assert.js | 336 ++++++++++++++++++++--------------- 1 file changed, 192 insertions(+), 144 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 3132c52504421d..c85f52033be23b 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -38,7 +38,7 @@ const start = 'Expected values to be strictly deep-equal:'; const actExp = '+ actual - expected'; assert.ok(a.AssertionError.prototype instanceof Error, - 'a.AssertionError instanceof Error'); + 'a.AssertionError instanceof Error'); assert.throws(() => a(false), a.AssertionError, 'ok(false)'); assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)'); @@ -55,6 +55,52 @@ assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)'); assert.ok(threw, 'Error: ok(false)'); } +// Throw message if the message is instanceof Error. +{ + let threw = false; + const context = vm.createContext(); + try { + const errorConstructor = vm.runInContext('Error', context); + const customError = new errorConstructor('ok(false)'); + assert.ok(false, customError.message); + } catch (e) { + threw = true; + assert.ok(e instanceof Error); + } + assert.ok(threw, 'Error: ok(false)'); +} + +// Throw message if the message is instanceof TypeError. +{ + let threw = false; + const context = vm.createContext(); + context.TypeError = TypeError; + try { + const TypeErrorConstructor = vm.runInContext('TypeError', context); + const customTypeError = new TypeErrorConstructor('ok(false)'); + assert.ok(false, customTypeError); + } catch (e) { + threw = true; + assert.ok(e instanceof Error); + } + assert.ok(threw, 'TypeError: ok(false)'); +} + +// Throw message if the message is instanceof SyntaxError. +{ + let threw = false; + const context = vm.createContext(); + context.SyntaxError = SyntaxError; + try { + const SyntaxErrorConstructor = vm.runInContext('SyntaxError', context); + const customSyntaxError = new SyntaxErrorConstructor('ok(false)'); + assert.ok(false, customSyntaxError); + } catch (e) { + threw = true; + assert.ok(e instanceof Error); + } + assert.ok(threw, 'SyntaxError: ok(false)'); +} a(true); a('test', 'ok(\'test\')'); @@ -62,7 +108,7 @@ a.ok(true); a.ok('test'); assert.throws(() => a.equal(true, false), - a.AssertionError, 'equal(true, false)'); + a.AssertionError, 'equal(true, false)'); a.equal(null, null); a.equal(undefined, undefined); @@ -72,14 +118,14 @@ a.equal(2, '2'); a.notEqual(true, false); assert.throws(() => a.notEqual(true, true), - a.AssertionError, 'notEqual(true, true)'); + a.AssertionError, 'notEqual(true, true)'); assert.throws(() => a.strictEqual(2, '2'), - a.AssertionError, 'strictEqual(2, \'2\')'); + a.AssertionError, 'strictEqual(2, \'2\')'); /* eslint-disable no-restricted-syntax */ assert.throws(() => a.strictEqual(null, undefined), - a.AssertionError, 'strictEqual(null, undefined)'); + a.AssertionError, 'strictEqual(null, undefined)'); assert.throws( () => a.notStrictEqual(2, 2), @@ -93,7 +139,7 @@ assert.throws( () => a.notStrictEqual('a '.repeat(30), 'a '.repeat(30)), { message: 'Expected "actual" to be strictly unequal to:\n\n' + - `'${'a '.repeat(30)}'`, + `'${'a '.repeat(30)}'`, name: 'AssertionError' } ); @@ -132,7 +178,7 @@ assert.throws( name: 'AssertionError', operator: 'throws', message: 'The error is expected to be an instance of "AssertionError". ' + - 'Received "TypeError"\n\nError message:\n\n[object Object]' + 'Received "TypeError"\n\nError message:\n\n[object Object]' } ); @@ -168,7 +214,7 @@ assert.throws( code: 'ERR_ASSERTION', operator: 'doesNotThrow', message: 'Got unwanted exception: user message\n' + - 'Actual message: "[object Object]"' + 'Actual message: "[object Object]"' } ); @@ -187,7 +233,7 @@ assert.throws( code: 'ERR_ASSERTION', operator: 'doesNotThrow', message: 'Got unwanted exception: user message\n' + - 'Actual message: "[object Object]"' + 'Actual message: "[object Object]"' } ); @@ -222,7 +268,7 @@ assert.throws( }, /abc/); }, { message: 'The input did not match the regular expression /abc/. ' + - "Input:\n\n'Symbol(foo)'\n", + "Input:\n\n'Symbol(foo)'\n", code: 'ERR_ASSERTION', operator: 'throws', actual: symbol, @@ -242,8 +288,8 @@ a.throws(() => thrower(TypeError), (err) => { let actual; assert.throws( () => { - const ES6Error = class extends Error {}; - const AnotherErrorType = class extends Error {}; + const ES6Error = class extends Error { }; + const AnotherErrorType = class extends Error { }; assert.throws(() => { actual = new AnotherErrorType('foo'); @@ -254,7 +300,7 @@ a.throws(() => thrower(TypeError), (err) => { assert.strictEqual( err.message, 'The error is expected to be an instance of "ES6Error". ' + - 'Received "AnotherErrorType"\n\nError message:\n\nfoo' + 'Received "AnotherErrorType"\n\nError message:\n\nfoo' ); assert.strictEqual(err.actual, actual); return true; @@ -264,7 +310,7 @@ a.throws(() => thrower(TypeError), (err) => { // Check messages from assert.throws(). { - const noop = () => {}; + const noop = () => { }; assert.throws( () => { a.throws((noop)); }, { @@ -322,14 +368,14 @@ function testAssertionMessage(actual, expected, msg) { { generatedMessage: true, message: msg || strictEqualMessageStart + - `+ actual - expected\n\n+ ${expected}\n- ''` + `+ actual - expected\n\n+ ${expected}\n- ''` } ); } function testShortAssertionMessage(actual, expected) { testAssertionMessage(actual, expected, strictEqualMessageStart + - `\n${inspect(actual)} !== ''\n`); + `\n${inspect(actual)} !== ''\n`); } testShortAssertionMessage(null, 'null'); @@ -349,14 +395,14 @@ testAssertionMessage(/a/, '/a/'); testAssertionMessage(/abc/gim, '/abc/gim'); testAssertionMessage({}, '{}'); testAssertionMessage([1, 2, 3], '[\n+ 1,\n+ 2,\n+ 3\n+ ]'); -testAssertionMessage(function f() {}, '[Function: f]'); -testAssertionMessage(function() {}, '[Function (anonymous)]'); +testAssertionMessage(function f() { }, '[Function: f]'); +testAssertionMessage(function () { }, '[Function (anonymous)]'); testAssertionMessage(circular, - ' {\n+ x: [Circular *1],\n+ y: 1\n+ }'); + ' {\n+ x: [Circular *1],\n+ y: 1\n+ }'); testAssertionMessage({ a: undefined, b: null }, - '{\n+ a: undefined,\n+ b: null\n+ }'); + '{\n+ a: undefined,\n+ b: null\n+ }'); testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity }, - '{\n+ a: NaN,\n+ b: Infinity,\n+ c: -Infinity\n+ }'); + '{\n+ a: NaN,\n+ b: Infinity,\n+ c: -Infinity\n+ }'); // /~https://github.com/nodejs/node-v0.x-archive/issues/5292 assert.throws( @@ -413,7 +459,7 @@ assert.throws( code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: 'The "fn" argument must be of type function.' + - common.invalidArgTypeHelper(fn) + common.invalidArgTypeHelper(fn) } ); }; @@ -449,8 +495,8 @@ assert.throws(() => { }, (err) => { assert.strictEqual(err.code, 'ERR_ASSERTION'); assert.strictEqual(err.message, - `${strictEqualMessageStart}+ actual - expected\n\n` + - `+ '${'A'.repeat(1000)}'\n- ''`); + `${strictEqualMessageStart}+ actual - expected\n\n` + + `+ '${'A'.repeat(1000)}'\n- ''`); assert.strictEqual(err.actual.length, 1000); assert.ok(inspect(err).includes(`actual: '${'A'.repeat(488)}...'`)); return true; @@ -483,7 +529,7 @@ assert.throws(() => { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: 'The "options" argument must be of type object.' + - common.invalidArgTypeHelper(input) + common.invalidArgTypeHelper(input) }); } } @@ -494,8 +540,8 @@ assert.throws( code: 'ERR_ASSERTION', name: 'AssertionError', message: 'Expected "actual" to be reference-equal to "expected":\n' + - '+ actual - expected\n\n' + - '+ [Error: foo]\n- [Error: foobar]' + '+ actual - expected\n\n' + + '+ [Error: foo]\n- [Error: foobar]' } ); @@ -550,7 +596,7 @@ a.throws( code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n ' + - "assert.ok(\n typeof 123 === 'string'\n )\n" + "assert.ok(\n typeof 123 === 'string'\n )\n" } ); Error.stackTraceLimit = tmpLimit; @@ -687,13 +733,13 @@ a.throws( // No infinite loop and no custom inspect. assert.throws(() => assert.deepEqual(obj1, obj2), { message: `${start}\n` + - `${actExp}\n` + - '\n' + - '+ {}\n' + - '- {\n' + - '- [Symbol(nodejs.util.inspect.custom)]: [Function (anonymous)],\n' + - "- loop: 'forever'\n" + - '- }' + `${actExp}\n` + + '\n' + + '+ {}\n' + + '- {\n' + + '- [Symbol(nodejs.util.inspect.custom)]: [Function (anonymous)],\n' + + "- loop: 'forever'\n" + + '- }' }); // notDeepEqual tests @@ -701,12 +747,12 @@ a.throws( () => assert.notDeepEqual([1], [1]), { message: 'Expected "actual" not to be strictly deep-equal to:\n\n' + - '[\n 1\n]\n' + '[\n 1\n]\n' } ); message = 'Expected "actual" not to be strictly deep-equal to:' + - `\n\n[${'\n 1,'.repeat(45)}\n...\n`; + `\n\n[${'\n 1,'.repeat(45)}\n...\n`; const data = Array(51).fill(1); assert.throws( () => assert.notDeepEqual(data, data), @@ -721,7 +767,7 @@ assert.throws( constructor: assert.AssertionError, generatedMessage: true, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert.ok(null)\n' + 'assert.ok(null)\n' } ); assert.throws( @@ -730,7 +776,8 @@ assert.throws( // before the assertion causes any wrong assertion message. // Therefore, don't reformat the following code. // Refs: /~https://github.com/nodejs/node/issues/30872 - try { assert.ok(0); // eslint-disable-line no-useless-catch, brace-style + try { + assert.ok(0); // eslint-disable-line no-useless-catch, brace-style } catch (err) { throw err; } @@ -740,17 +787,17 @@ assert.throws( constructor: assert.AssertionError, generatedMessage: true, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert.ok(0)\n' + 'assert.ok(0)\n' } ); assert.throws( () => { try { throw new Error(); - // This test case checks if `catch` left brace without a line break - // before the assertion causes any wrong assertion message. - // Therefore, don't reformat the following code. - // Refs: /~https://github.com/nodejs/node/issues/30872 + // This test case checks if `catch` left brace without a line break + // before the assertion causes any wrong assertion message. + // Therefore, don't reformat the following code. + // Refs: /~https://github.com/nodejs/node/issues/30872 } catch (err) { assert.ok(0); } // eslint-disable-line no-unused-vars }, { @@ -758,7 +805,7 @@ assert.throws( constructor: assert.AssertionError, generatedMessage: true, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert.ok(0)\n' + 'assert.ok(0)\n' } ); assert.throws( @@ -767,7 +814,8 @@ assert.throws( // before the assertion causes any wrong assertion message. // Therefore, don't reformat the following code. // Refs: /~https://github.com/nodejs/node/issues/30872 - function test() { assert.ok(0); // eslint-disable-line brace-style + function test() { + assert.ok(0); // eslint-disable-line brace-style } test(); }, @@ -776,7 +824,7 @@ assert.throws( constructor: assert.AssertionError, generatedMessage: true, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert.ok(0)\n' + 'assert.ok(0)\n' } ); assert.throws( @@ -786,7 +834,7 @@ assert.throws( constructor: assert.AssertionError, generatedMessage: true, message: 'The expression evaluated to a falsy value:\n\n ' + - "assert(typeof 123n === 'string')\n" + "assert(typeof 123n === 'string')\n" } ); @@ -807,20 +855,20 @@ assert.throws( // eslint-disable-next-line operator-linebreak === 123 instanceof - Buffer + Buffer ); }, { code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n' + - ' a(\n' + - ' (() => \'string\')()\n' + - ' // eslint-disable-next-line operator-linebreak\n' + - ' ===\n' + - ' 123 instanceof\n' + - ' Buffer\n' + - ' )\n' + ' a(\n' + + ' (() => \'string\')()\n' + + ' // eslint-disable-next-line operator-linebreak\n' + + ' ===\n' + + ' 123 instanceof\n' + + ' Buffer\n' + + ' )\n' } ); @@ -830,41 +878,41 @@ assert.throws( (() => 'string')() // eslint-disable-next-line operator-linebreak === - 123 instanceof - Buffer + 123 instanceof + Buffer ); }, { code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n' + - ' a(\n' + - ' (() => \'string\')()\n' + - ' // eslint-disable-next-line operator-linebreak\n' + - ' ===\n' + - ' 123 instanceof\n' + - ' Buffer\n' + - ' )\n' + ' a(\n' + + ' (() => \'string\')()\n' + + ' // eslint-disable-next-line operator-linebreak\n' + + ' ===\n' + + ' 123 instanceof\n' + + ' Buffer\n' + + ' )\n' } ); /* eslint-disable indent */ assert.throws(() => { -a(( - () => 'string')() === -123 instanceof -Buffer -); + a(( + () => 'string')() === + 123 instanceof + Buffer + ); }, { code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n' + - ' a((\n' + - ' () => \'string\')() ===\n' + - ' 123 instanceof\n' + - ' Buffer\n' + - ' )\n' - } + ' a((\n' + + ' () => \'string\')() ===\n' + + ' 123 instanceof\n' + + ' Buffer\n' + + ' )\n' +} ); /* eslint-enable indent */ @@ -876,20 +924,20 @@ assert.throws( code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert(null, undefined)\n' + 'assert(null, undefined)\n' } ); assert.throws( () => { assert - .ok(null, undefined); + .ok(null, undefined); }, { code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n ' + - 'ok(null, undefined)\n' + 'ok(null, undefined)\n' } ); @@ -900,7 +948,7 @@ assert.throws( code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert[\'ok\']["apply"](null, [0])\n' + 'assert[\'ok\']["apply"](null, [0])\n' } ); @@ -922,7 +970,7 @@ assert.throws( code: 'ERR_ASSERTION', constructor: assert.AssertionError, message: 'The expression evaluated to a falsy value:\n\n ' + - 'assert.ok.call(null, 0)\n', + 'assert.ok.call(null, 0)\n', generatedMessage: true } ); @@ -955,25 +1003,25 @@ assert.throws( ); assert.throws( - () => assert.throws(() => {}, 'Error message', 'message'), + () => assert.throws(() => { }, 'Error message', 'message'), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', message: 'The "error" argument must be of type function or ' + - 'an instance of Error, RegExp, or Object. Received type string ' + - "('Error message')" + 'an instance of Error, RegExp, or Object. Received type string ' + + "('Error message')" } ); const inputs = [1, false, Symbol()]; for (const input of inputs) { assert.throws( - () => assert.throws(() => {}, input), + () => assert.throws(() => { }, input), { code: 'ERR_INVALID_ARG_TYPE', message: 'The "error" argument must be of type function or ' + - 'an instance of Error, RegExp, or Object.' + - common.invalidArgTypeHelper(input) + 'an instance of Error, RegExp, or Object.' + + common.invalidArgTypeHelper(input) } ); } @@ -984,7 +1032,7 @@ for (const input of inputs) { assert.ok((() => Boolean('' === false))()); }, { message: 'The expression evaluated to a falsy value:\n\n' + - " assert.ok((() => Boolean('\\u0001' === false))())\n" + " assert.ok((() => Boolean('\\u0001' === false))())\n" }); const errFn = () => { @@ -1010,12 +1058,12 @@ for (const input of inputs) { code: 'ERR_ASSERTION', name: 'AssertionError', message: `${start}\n${actExp}\n\n` + - ' Comparison {\n' + - ' code: 404,\n' + - '- foo: undefined,\n' + - " message: 'Wrong value',\n" + - " name: 'TypeError'\n" + - ' }' + ' Comparison {\n' + + ' code: 404,\n' + + '- foo: undefined,\n' + + " message: 'Wrong value',\n" + + " name: 'TypeError'\n" + + ' }' } ); @@ -1027,13 +1075,13 @@ for (const input of inputs) { code: 'ERR_ASSERTION', name: 'AssertionError', message: `${start}\n${actExp}\n\n` + - ' Comparison {\n' + - '+ code: 404,\n' + - "- code: '404',\n" + - '- foo: undefined,\n' + - " message: 'Wrong value',\n" + - " name: 'TypeError'\n" + - ' }' + ' Comparison {\n' + + '+ code: 404,\n' + + "- code: '404',\n" + + '- foo: undefined,\n' + + " message: 'Wrong value',\n" + + " name: 'TypeError'\n" + + ' }' } ); @@ -1052,7 +1100,7 @@ for (const input of inputs) { name: 'TypeError', code: 'ERR_INVALID_ARG_TYPE', message: 'The "expected" argument must be of type function or an ' + - 'instance of RegExp. Received an instance of Object' + 'instance of RegExp. Received an instance of Object' } ); @@ -1063,11 +1111,11 @@ for (const input of inputs) { name: 'AssertionError', code: 'ERR_ASSERTION', message: `${start}\n${actExp}\n\n` + - ' Comparison {\n' + - " message: 'e',\n" + - "+ name: 'TypeError'\n" + - "- name: 'Error'\n" + - ' }' + ' Comparison {\n' + + " message: 'e',\n" + + "+ name: 'TypeError'\n" + + "- name: 'Error'\n" + + ' }' } ); assert.throws( @@ -1077,11 +1125,11 @@ for (const input of inputs) { code: 'ERR_ASSERTION', generatedMessage: true, message: `${start}\n${actExp}\n\n` + - ' Comparison {\n' + - "+ message: 'foo',\n" + - "- message: '',\n" + - " name: 'Error'\n" + - ' }' + ' Comparison {\n' + + "+ message: 'foo',\n" + + "- message: '',\n" + + " name: 'Error'\n" + + ' }' } ); @@ -1115,7 +1163,7 @@ assert.throws( { code: 'ERR_AMBIGUOUS_ARGUMENT', message: 'The "error/message" argument is ambiguous. ' + - 'The error "foo" is identical to the message.' + 'The error "foo" is identical to the message.' } ); @@ -1127,7 +1175,7 @@ assert.throws( { code: 'ERR_AMBIGUOUS_ARGUMENT', message: 'The "error/message" argument is ambiguous. ' + - 'The error message "foo" is identical to the message.' + 'The error message "foo" is identical to the message.' } ); /* eslint-enable no-restricted-syntax */ @@ -1144,13 +1192,13 @@ assert.throws( ); { - const args = (function() { return arguments; })('a'); + const args = (function () { return arguments; })('a'); assert.throws( () => assert.strictEqual(args, { 0: 'a' }), { message: 'Expected "actual" to be reference-equal to "expected":\n' + - '+ actual - expected\n\n' + - "+ [Arguments] {\n- {\n '0': 'a'\n }" + '+ actual - expected\n\n' + + "+ [Arguments] {\n- {\n '0': 'a'\n }" } ); } @@ -1173,11 +1221,11 @@ assert.throws( ), { message: `${start}\n${actExp}\n\n` + - ' Comparison {\n' + - "+ message: 'foobar',\n" + - '- message: /fooa/,\n' + - " name: 'TypeError'\n" + - ' }' + ' Comparison {\n' + + "+ message: 'foobar',\n" + + '- message: /fooa/,\n' + + " name: 'TypeError'\n" + + ' }' } ); @@ -1195,10 +1243,10 @@ assert.throws( expected, generatedMessage: true, message: `${start}\n${actExp}\n\n` + - '+ null\n' + - '- {\n' + - "- message: 'foo'\n" + - '- }' + '+ null\n' + + '- {\n' + + "- message: 'foo'\n" + + '- }' } ); @@ -1226,10 +1274,10 @@ assert.throws( code: 'ERR_ASSERTION', name: 'AssertionError', message: strictEqualMessageStart + - '+ actual - expected\n\n' + - "+ 'test test'\n" + - "- 'test foobar'\n" + - ' ^' + '+ actual - expected\n\n' + + "+ 'test test'\n" + + "- 'test foobar'\n" + + ' ^' } ); @@ -1255,7 +1303,7 @@ assert.throws( code: 'ERR_ASSERTION', name: 'AssertionError', message: 'Expected "actual" not to be reference-equal to "expected":\n\n' + - '{\n a: true\n}\n' + '{\n a: true\n}\n' } ); @@ -1343,7 +1391,7 @@ assert.throws( () => assert.throws(() => { throw Symbol('foo'); }, RangeError), { message: 'The error is expected to be an instance of "RangeError". ' + - 'Received "Symbol(foo)"' + 'Received "Symbol(foo)"' } ); @@ -1352,19 +1400,19 @@ assert.throws( () => assert.throws(() => { throw [1, 2]; }, RangeError), { message: 'The error is expected to be an instance of "RangeError". ' + - 'Received "[Array]"' + 'Received "[Array]"' } ); { const err = new TypeError('foo'); - const validate = (() => () => ({ a: true, b: [ 1, 2, 3 ] }))(); + const validate = (() => () => ({ a: true, b: [1, 2, 3] }))(); assert.throws( () => assert.throws(() => { throw err; }, validate), { message: 'The validation function is expected to ' + - `return "true". Received ${inspect(validate())}\n\nCaught ` + - `error:\n\n${err}`, + `return "true". Received ${inspect(validate())}\n\nCaught ` + + `error:\n\n${err}`, code: 'ERR_ASSERTION', actual: err, expected: validate, @@ -1383,8 +1431,8 @@ assert.throws( }, { message: 'The error is expected to be an instance of "RangeError". ' + - 'Received an error with identical name but a different ' + - 'prototype.\n\nError message:\n\nfoobar' + 'Received an error with identical name but a different ' + + 'prototype.\n\nError message:\n\nfoobar' } ); @@ -1395,7 +1443,7 @@ assert.throws( { code: 'ERR_INVALID_ARG_TYPE', message: 'The "regexp" argument must be an instance of RegExp. ' + - "Received type string ('string')" + "Received type string ('string')" } ); assert.throws( @@ -1405,7 +1453,7 @@ assert.throws( expected: /abc/, operator: 'match', message: 'The input did not match the regular expression /abc/. ' + - "Input:\n\n'string'\n", + "Input:\n\n'string'\n", generatedMessage: true } ); @@ -1431,7 +1479,7 @@ assert.throws( expected: /abc/, operator: 'match', message: 'The "string" argument must be of type string. ' + - 'Received type object ({ abc: 123 })', + 'Received type object ({ abc: 123 })', generatedMessage: true } ); @@ -1445,7 +1493,7 @@ assert.throws( { code: 'ERR_INVALID_ARG_TYPE', message: 'The "regexp" argument must be an instance of RegExp. ' + - "Received type string ('string')" + "Received type string ('string')" } ); assert.throws( @@ -1455,7 +1503,7 @@ assert.throws( expected: /string/, operator: 'doesNotMatch', message: 'The input was expected to not match the regular expression ' + - "/string/. Input:\n\n'string'\n", + "/string/. Input:\n\n'string'\n", generatedMessage: true } ); @@ -1481,7 +1529,7 @@ assert.throws( expected: /abc/, operator: 'doesNotMatch', message: 'The "string" argument must be of type string. ' + - 'Received type object ({ abc: 123 })', + 'Received type object ({ abc: 123 })', generatedMessage: true } );