diff --git a/test/common/README.md b/test/common/README.md index f064ab6e7e14be..a737bca2de5e9f 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -377,10 +377,12 @@ const { spawn } = require('child_process'); spawn(...common.pwdCommand, { stdio: ['pipe'] }); ``` -### `requireNoPackageJSONAbove()` +### `requireNoPackageJSONAbove([dir])` -Throws an `AssertionError` if a `package.json` file is in any ancestor -directory. Such files may interfere with proper test functionality. +* `dir` [<string>][] default = \_\_dirname + +Throws an `AssertionError` if a `package.json` file exists in any ancestor +directory above `dir`. Such files may interfere with proper test functionality. ### `runWithInvalidFD(func)` diff --git a/test/common/index.js b/test/common/index.js index 7480368a55ebb3..ae18ee6a75f10c 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -699,8 +699,8 @@ function gcUntil(name, condition) { }); } -function requireNoPackageJSONAbove() { - let possiblePackage = path.join(__dirname, '..', 'package.json'); +function requireNoPackageJSONAbove(dir = __dirname) { + let possiblePackage = path.join(dir, '..', 'package.json'); let lastPackage = null; while (possiblePackage !== lastPackage) { if (fs.existsSync(possiblePackage)) { diff --git a/test/pummel/test-policy-integrity.js b/test/pummel/test-policy-integrity.js index 15124aefd46904..c29bb7a7b3f90e 100644 --- a/test/pummel/test-policy-integrity.js +++ b/test/pummel/test-policy-integrity.js @@ -76,6 +76,7 @@ function newTestId() { return nextTestId++; } tmpdir.refresh(); +common.requireNoPackageJSONAbove(tmpdir.path); let spawned = 0; const toSpawn = [];