node/test/parallel/test-async-hooks-run-in-async-scope-this-arg.js
Rich Trott 73b8909501 test: increase runInAsyncScope() coverage
We don't appear to have any test coverage for passing the `thisArg`
argument to `runInAsyncScope()`. Test coverage stats seem to bear this
out. Add a test for it.

PR-URL: https://github.com/nodejs/node/pull/36624
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2020-12-26 20:28:42 -08:00

18 lines
380 B
JavaScript

'use strict';
// Test that passing thisArg to runInAsyncScope() works.
const common = require('../common');
const assert = require('assert');
const { AsyncResource } = require('async_hooks');
const thisArg = {};
const res = new AsyncResource('fhqwhgads');
function callback() {
assert.strictEqual(this, thisArg);
}
res.runInAsyncScope(common.mustCall(callback), thisArg);