• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4const assert = require('assert');
5
6// No args
7assert.throws(
8  () => { assert.fail(); },
9  {
10    code: 'ERR_ASSERTION',
11    name: 'AssertionError',
12    message: 'Failed',
13    operator: 'fail',
14    actual: undefined,
15    expected: undefined,
16    generatedMessage: true,
17    stack: /Failed/
18  }
19);
20
21// One arg = message
22assert.throws(() => {
23  assert.fail('custom message');
24}, {
25  code: 'ERR_ASSERTION',
26  name: 'AssertionError',
27  message: 'custom message',
28  operator: 'fail',
29  actual: undefined,
30  expected: undefined,
31  generatedMessage: false
32});
33
34// One arg = Error
35assert.throws(() => {
36  assert.fail(new TypeError('custom message'));
37}, {
38  name: 'TypeError',
39  message: 'custom message'
40});
41