mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Track the test that owns the current async context with an AsyncLocalStorage instead of a createHook() init/destroy map. Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/66795 Refs: https://github.com/nodejs/node/pull/61030 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
23 lines
718 B
JavaScript
23 lines
718 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
// The test runner tracks which test owns the current async context with
|
|
// AsyncLocalStorage, so it must not install any async_hooks.
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { setTimeout } = require('timers/promises');
|
|
const { enabledHooksExist } = require('internal/async_hooks');
|
|
const { test } = require('node:test');
|
|
|
|
test('no async hooks are enabled', common.mustCall(async (t) => {
|
|
assert.strictEqual(enabledHooksExist(), false);
|
|
|
|
await t.test('subtest', common.mustCall(async () => {
|
|
await setTimeout(1);
|
|
assert.strictEqual(enabledHooksExist(), false);
|
|
}));
|
|
|
|
assert.strictEqual(enabledHooksExist(), false);
|
|
}));
|