diff --git a/implementors/node/features.js b/implementors/node/features.js index 27286f8..b83da9e 100644 --- a/implementors/node/features.js +++ b/implementors/node/features.js @@ -8,8 +8,6 @@ globalThis.experimentalFeatures = { postFinalizer: true, }; -globalThis.napiVersion = Number(process.versions.napi); - globalThis.skipTest = () => { process.exit(0); }; diff --git a/implementors/node/napi-version.js b/implementors/node/napi-version.js new file mode 100644 index 0000000..a6f518d --- /dev/null +++ b/implementors/node/napi-version.js @@ -0,0 +1 @@ +globalThis.napiVersion = Number(process.versions.napi); diff --git a/implementors/node/tests.ts b/implementors/node/tests.ts index d4f8b2c..26e6a57 100644 --- a/implementors/node/tests.ts +++ b/implementors/node/tests.ts @@ -40,6 +40,12 @@ const MUST_CALL_MODULE_PATH = path.join( "node", "must-call.js" ); +const NAPI_VERSION_MODULE_PATH = path.join( + ROOT_PATH, + "implementors", + "node", + "napi-version.js" +); export function listDirectoryEntries(dir: string) { const entries = fs.readdirSync(dir, { withFileTypes: true }); @@ -80,6 +86,8 @@ export function runFileInSubprocess( "file://" + GC_MODULE_PATH, "--import", "file://" + MUST_CALL_MODULE_PATH, + "--import", + "file://" + NAPI_VERSION_MODULE_PATH, filePath, ], { cwd } diff --git a/tests/harness/napi-version.js b/tests/harness/napi-version.js new file mode 100644 index 0000000..78c792d --- /dev/null +++ b/tests/harness/napi-version.js @@ -0,0 +1,6 @@ +'use strict'; + +// napiVersion is a positive integer +if (typeof napiVersion !== 'number' || napiVersion < 1 || !Number.isInteger(napiVersion)) { + throw new Error('Expected a global napiVersion that is a positive integer'); +}