Skip to content

Commit 356e93d

Browse files
authored
test: fixup testing for specific N-API version (#840)
Fixup testing for a specific N-API version and document. Reviewed-By: NickNaso <[email protected]> PR-URL: #840
1 parent 63b43f4 commit 356e93d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ npm install
157157
npm test --disable-deprecated
158158
```
159159

160+
To run the tests targetting a specific version of N-API run
161+
```
162+
npm install
163+
export NAPI_VERSION=X
164+
npm test --NAPI_VERSION=X
165+
```
166+
167+
where X is the version of N-API you want to target.
168+
160169
### **Debug**
161170

162171
To run the **node-addon-api** tests with `--debug` option:

test/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ let testModules = [
6262
'version_management'
6363
];
6464

65-
const napiVersion = Number(process.versions.napi)
65+
let napiVersion = Number(process.versions.napi)
66+
if (process.env.NAPI_VERSION) {
67+
// we need this so that we don't try run tests that rely
68+
// on methods that are not available in the NAPI_VERSION
69+
// specified
70+
napiVersion = process.env.NAPI_VERSION;
71+
}
72+
console.log('napiVersion:' + napiVersion);
73+
6674
const majorNodeVersion = process.versions.node.split('.')[0]
6775

6876
if (napiVersion < 3) {

0 commit comments

Comments
 (0)