diff --git a/README.md b/README.md index 8e7ee39..4193533 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,15 @@ npm install npm test --disable-deprecated ``` +To run the tests targetting a specific version of N-API run +``` +npm install +export NAPI_VERSION=X +npm test --NAPI_VERSION=X +``` + +where X is the version of N-API you want to target. + ### **Debug** To run the **node-addon-api** tests with `--debug` option: diff --git a/test/index.js b/test/index.js index ac95d88..ece32b3 100644 --- a/test/index.js +++ b/test/index.js @@ -62,7 +62,15 @@ let testModules = [ 'version_management' ]; -const napiVersion = Number(process.versions.napi) +let napiVersion = Number(process.versions.napi) +if (process.env.NAPI_VERSION) { + // we need this so that we don't try run tests that rely + // on methods that are not available in the NAPI_VERSION + // specified + napiVersion = process.env.NAPI_VERSION; +} +console.log('napiVersion:' + napiVersion); + const majorNodeVersion = process.versions.node.split('.')[0] if (napiVersion < 3) {