mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
Tests should be explicit regarding whether a promise is expected to settle, and the test should fail when the behavior does not meet expectations. PR-URL: https://github.com/nodejs/node/pull/60976 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
27 lines
689 B
JavaScript
27 lines
689 B
JavaScript
// Test async-hooks fired on right
|
|
// asyncIds & triggerAsyncId for async-await
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const async_hooks = require('async_hooks');
|
|
const assert = require('assert');
|
|
|
|
const asyncIds = [];
|
|
async_hooks.createHook({
|
|
init: (asyncId, type, triggerAsyncId) => {
|
|
asyncIds.push([triggerAsyncId, asyncId]);
|
|
}
|
|
}).enable();
|
|
|
|
async function main() {
|
|
await null;
|
|
}
|
|
|
|
main().then(() => {
|
|
// Verify the relationships between async ids
|
|
// 1 => 2, 2 => 3 etc
|
|
assert.strictEqual(asyncIds[0][1], asyncIds[1][0]);
|
|
assert.strictEqual(asyncIds[0][1], asyncIds[3][0]);
|
|
assert.strictEqual(asyncIds[1][1], asyncIds[2][0]);
|
|
}).then(common.mustCall());
|