diff options
Diffstat (limited to 'test/parallel/test-assert-fail.js')
-rw-r--r-- | test/parallel/test-assert-fail.js | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js index 1b72310a16..99f7c4e3da 100644 --- a/test/parallel/test-assert-fail.js +++ b/test/parallel/test-assert-fail.js @@ -1,53 +1,76 @@ 'use strict'; + const common = require('../common'); const assert = require('assert'); -// no args +// No args assert.throws( () => { assert.fail(); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'Failed' + message: 'Failed', + operator: undefined, + actual: undefined, + expected: undefined }) ); -// one arg = message +// One arg = message assert.throws( () => { assert.fail('custom message'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'custom message' + message: 'custom message', + operator: undefined, + actual: undefined, + expected: undefined }) ); -// two args only, operator defaults to '!=' +// Two args only, operator defaults to '!=' assert.throws( () => { assert.fail('first', 'second'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: '\'first\' != \'second\'' + message: '\'first\' != \'second\'', + operator: '!=', + actual: 'first', + expected: 'second' + }) ); -// three args +// Three args assert.throws( () => { assert.fail('ignored', 'ignored', 'another custom message'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: 'another custom message' + message: 'another custom message', + operator: undefined, + actual: 'ignored', + expected: 'ignored' }) ); -// no third arg (but a fourth arg) +// No third arg (but a fourth arg) assert.throws( () => { assert.fail('first', 'second', undefined, 'operator'); }, common.expectsError({ code: 'ERR_ASSERTION', type: assert.AssertionError, - message: '\'first\' operator \'second\'' + message: '\'first\' operator \'second\'', + operator: 'operator', + actual: 'first', + expected: 'second' }) ); + +// The stackFrameFunction should exclude the foo frame +assert.throws( + function foo() { assert.fail('first', 'second', 'message', '!==', foo); }, + (err) => !/foo/m.test(err.stack) +); |