Skip to content

Commit

Permalink
async_hooks: Adding regression test case for async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
antsmartian committed Aug 22, 2018
1 parent 6acb550 commit 8f4ad83
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/parallel/test-async-hooks-async-await.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Test async-hooks fired on right
// asyncIds & triggerAsyncId for async-await
'use strict';

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]);
});

0 comments on commit 8f4ad83

Please sign in to comment.