node/test/parallel/test-promise-hook-exceptions.js
Rich Trott 6059cbedbd
test: remove unnecessary noop function args to mustCall()
PR-URL: https://github.com/nodejs/node/pull/45027
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-10-18 12:13:41 +00:00

32 lines
657 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { promiseHooks } = require('v8');
const expected = [];
function testHook(name) {
const hook = promiseHooks[name];
const error = new Error(`${name} error`);
const stop = hook(common.mustCall(() => {
stop();
throw error;
}));
expected.push(error);
}
process.on('uncaughtException', common.mustCall((received) => {
assert.strictEqual(received, expected.shift());
}, 4));
testHook('onInit');
testHook('onSettled');
testHook('onBefore');
testHook('onAfter');
const stop = promiseHooks.onInit(common.mustCall(2));
Promise.resolve().then(stop);