Skip to content

Commit

Permalink
test: fixup testing for specific N-API version (#840)
Browse files Browse the repository at this point in the history
Fixup testing for a specific N-API version
and document.

Reviewed-By: NickNaso <nicoladelgobbo@gmail.com>
PR-URL: nodejs/node-addon-api#840
  • Loading branch information
kevindavies8 committed Nov 26, 2020
1 parent c1f0837 commit caa66da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit caa66da

Please sign in to comment.