1'use strict'; 2const common = require('../common'); 3 4// This tests ensures that the triggerId of the nextTick function sets the 5// triggerAsyncId correctly. 6 7const assert = require('assert'); 8const async_hooks = require('async_hooks'); 9const initHooks = require('./init-hooks'); 10const { checkInvocations } = require('./hook-checks'); 11 12const hooks = initHooks(); 13hooks.enable(); 14 15const rootAsyncId = async_hooks.executionAsyncId(); 16 17process.nextTick(common.mustCall(() => { 18 assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId); 19})); 20 21process.on('exit', () => { 22 hooks.sanityCheck(); 23 24 const as = hooks.activitiesOfTypes('TickObject'); 25 checkInvocations(as[0], { 26 init: 1, before: 1, after: 1, destroy: 1 27 }, 'when process exits'); 28}); 29