summaryrefslogtreecommitdiff
path: root/test/parallel/test-domain-set-uncaught-exception-capture-after-load.js
blob: e7cbffd00758e21b702e07f5cbac6303c6f15b0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const common = require('../common');
const assert = require('assert');

(function foobar() {
  require('domain');
})();

assert.throws(
  () => process.setUncaughtExceptionCaptureCallback(common.mustNotCall()),
  (err) => {
    common.expectsError(
      {
        code: 'ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE',
        type: Error,
        message: /^The `domain` module is in use, which is mutually/
      }
    )(err);

    assert(err.stack.includes('-'.repeat(40)),
           `expected ${err.stack} to contain dashes`);

    const location = `at foobar (${__filename}:`;
    assert(err.stack.includes(location),
           `expected ${err.stack} to contain ${location}`);
    return true;
  }
);