Skip to content
napi-bindings

Search

Search pages, projects and the Node-API reference

Runtimes

quickjs-napi

0.0.x

A Node-API implementation for QuickJS: addons built for Node.js load unchanged, resolving napi_* from the quickjs-napi executable.

1 star0 forksv0.0.2· Nov 18, 2026Apache-2.0
test/node-addon-api/harness/README.mdEdit on GitHub

node-addon-api test suite

test/node-addon-api holds the headers (napi.h, napi-inl.h, napi-inl.deprecated.h), the license and the test/ directory of node-addon-api (version in NODE_ADDON_API_VERSION), copied by

python3 tools/sync_node_addon_api.py <node-addon-api checkout>

which also applies the patches listed in the script and writes tests.cmake. Everything there except this harness/ directory is regenerated by the sync.

cmake/node_addon_api_tests.cmake (option QJSNAPI_NODE_ADDON_API_TESTS, ON by default) builds the eight bindings of test/binding.gyp with the defines of node_addon_api.gyp / common.gypi (NAPI_VERSION=10, C++ exceptions on or off) into build/<preset>/node-addon-api-tests/test/build/Release, and registers one CTest per test module, named naa/<module>:

ctest --preset unix-debug -R naa/

Harness (this directory)

File
common/index.js replaces upstream test/common/index.js (which needs readline, os and fs/promises): mustCall, runTest over the four bindings (binding, binding_noexcept, binding_noexcept_maybe, binding_custom_namespace), runTestInChildProcess with child_process.spawnSync and -e
run.js runs one module, as upstream test/index.js does for all of them (the module name is removed from process.argv: some tests decide from it whether they run as a child process)
preload.js loaded with NODE_OPTIONS=--require=..., so that the child processes the tests start get it too: registers assert (test/node/common/assert.js) and sets process.versions.node, which the tests read
index.js stand-in for the package's index.js (needsFlag: false), required by test/napi_child.js

Not run

Module Reason
addon_build, require_basic_finalizers not copied: they build an addon with npm install
exports checks the npm package's index.js (semver, package.json), not Node-API
objectwrap_worker_thread, error_terminating_environment need worker_threads

Patches (see PATCHES in the sync script)

Module Patch
async_context, async_progress_worker, async_progress_queue_worker, async_worker, callbackscope no async_hooks: the tests take their path for Node.js < 8, which runs the same native code without checking hook events
async_worker in that path, {} instead of a null resource: the binding built with NODE_ADDON_API_ENABLE_TYPE_CHECK_ON_AS turns null into a fatal error (Node.js never runs that path)
function_reference the async_hooks part (canCallAsyncFunctionWithDifferentOverloads) is removed
array_buffer no WebAssembly: the buffer is detached with ArrayBuffer.prototype.transfer() instead of WebAssembly.Memory.grow()
object/object_freeze_seal V8 error messages matched by regular expression: TypeError is checked instead

Notes

  • async_progress_worker runs alone (RUN_SERIAL): its SignalAfterProgressTestWorker case is racy upstream (Send then Signal from the worker thread; if the loop thread handles the first call in between, the second sees no data), under Node.js as well.
  • The bindings are compiled with -fno-sanitize=alignment: DataView::ReadData in napi-inl.h reads through misaligned pointers.
  • test/lsan.supp suppresses the leaks of the test code and of Napi::ThreadSafeFunction (its call wrappers are deleted only when the callback returns normally), as under Node.js.
  • Running the suite found three differences that were fixed in the runtime: napi_define_class with an instance key defined twice (V8 templates replace), weak references to objects that QuickJS freed at once (kept objects, see the README), and process.exit() tearing the environment down (Node.js does not).