mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
a1c96f8e07
This switches the assert.throws output to the one used in strict mode if a error object is used for comparison. From now on it will show the complete difference between two objects instead of only showing the first failing property. It also fixes detecting properties with a undefined value and fails in case the thrown error does not contain the value at all. PR-URL: https://github.com/nodejs/node/pull/19463 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
38 lines
699 B
JavaScript
38 lines
699 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
// No args
|
|
assert.throws(
|
|
() => { assert.fail(); },
|
|
{
|
|
code: 'ERR_ASSERTION',
|
|
name: 'AssertionError [ERR_ASSERTION]',
|
|
message: 'Failed',
|
|
operator: undefined,
|
|
actual: undefined,
|
|
expected: undefined
|
|
}
|
|
);
|
|
|
|
// One arg = message
|
|
assert.throws(() => {
|
|
assert.fail('custom message');
|
|
}, {
|
|
code: 'ERR_ASSERTION',
|
|
name: 'AssertionError [ERR_ASSERTION]',
|
|
message: 'custom message',
|
|
operator: undefined,
|
|
actual: undefined,
|
|
expected: undefined
|
|
});
|
|
|
|
// One arg = Error
|
|
assert.throws(() => {
|
|
assert.fail(new TypeError('custom message'));
|
|
}, {
|
|
name: 'TypeError',
|
|
message: 'custom message'
|
|
});
|