Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fixup testing for specific N-API version #840

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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