Skip to content

Commit

Permalink
test: increase runInAsyncScope() coverage
Browse files Browse the repository at this point in the history
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: #36624
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
Trott authored and targos committed May 1, 2021
1 parent f65b842 commit e82a2e8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/parallel/test-async-hooks-run-in-async-scope-this-arg.js
@@ -0,0 +1,17 @@
'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);

0 comments on commit e82a2e8

Please sign in to comment.