@@ -23,87 +23,136 @@ in `js_native_api.h` and is therefore engine-agnostic.
2323## Difficulty Ratings
2424
2525Difficulty is assessed on two axes:
26+
2627- ** Size/complexity** — total lines of C/C++ and JS across all source files
2728- ** Runtime-API dependence** — pure ` js_native_api.h ` is cheapest; Node.js extensions and direct
2829 libuv calls require harness work or Node-only scoping
2930
30- | Rating | Meaning |
31- | ---| ---|
32- | Easy | Small test, pure ` js_native_api.h ` or trivial runtime API, straightforward 1:1 port |
33- | Medium | Moderate size or uses a Node.js extension API that the harness will need to abstract |
34- | Hard | Large test and/or deep libuv/worker/SEA dependency; may need new harness primitives or Node-only scoping |
31+ | Rating | Meaning |
32+ | ------ | -------------------------------------------------------------------------------------------------------- |
33+ | Easy | Small test, pure ` js_native_api.h ` or trivial runtime API, straightforward 1:1 port |
34+ | Medium | Moderate size or uses a Node.js extension API that the harness will need to abstract |
35+ | Hard | Large test and/or deep libuv/worker/SEA dependency; may need new harness primitives or Node-only scoping |
3536
3637## Engine-specific (` js-native-api ` )
3738
3839Tests covering the engine-specific part of Node-API, defined in ` js_native_api.h ` .
3940
40- | Directory | Status | Difficulty |
41- | ---| ---| ---|
42- | ` 2_function_arguments ` | Ported | — |
43- | ` 3_callbacks ` | Not ported | Easy |
44- | ` 4_object_factory ` | Not ported | Easy |
45- | ` 5_function_factory ` | Not ported | Easy |
46- | ` 6_object_wrap ` | Not ported | Medium |
47- | ` 7_factory_wrap ` | Not ported | Easy |
48- | ` 8_passing_wrapped ` | Not ported | Easy |
49- | ` test_array ` | Not ported | Easy |
50- | ` test_bigint ` | Not ported | Easy |
51- | ` test_cannot_run_js ` | Not ported | Medium |
52- | ` test_constructor ` | Not ported | Medium |
53- | ` test_conversions ` | Not ported | Medium |
54- | ` test_dataview ` | Not ported | Easy |
55- | ` test_date ` | Not ported | Easy |
56- | ` test_error ` | Not ported | Medium |
57- | ` test_exception ` | Not ported | Medium |
58- | ` test_finalizer ` | Not ported | Medium |
59- | ` test_function ` | Not ported | Medium |
60- | ` test_general ` | Not ported | Hard |
61- | ` test_handle_scope ` | Not ported | Easy |
62- | ` test_instance_data ` | Not ported | Easy |
63- | ` test_new_target ` | Not ported | Easy |
64- | ` test_number ` | Not ported | Easy |
65- | ` test_object ` | Not ported | Hard |
66- | ` test_promise ` | Not ported | Easy |
67- | ` test_properties ` | Not ported | Easy |
68- | ` test_reference ` | Not ported | Medium |
69- | ` test_reference_double_free ` | Not ported | Easy |
70- | ` test_sharedarraybuffer ` | Not ported | Medium |
71- | ` test_string ` | Not ported | Medium |
72- | ` test_symbol ` | Not ported | Easy |
73- | ` test_typedarray ` | Not ported | Medium |
41+ | Directory | Status | Difficulty |
42+ | ---------------------------- | ---------- | ---------- |
43+ | ` 2_function_arguments ` | Ported | — |
44+ | ` 3_callbacks ` | Not ported | Easy |
45+ | ` 4_object_factory ` | Not ported | Easy |
46+ | ` 5_function_factory ` | Not ported | Easy |
47+ | ` 6_object_wrap ` | Not ported | Medium |
48+ | ` 7_factory_wrap ` | Not ported | Easy |
49+ | ` 8_passing_wrapped ` | Not ported | Easy |
50+ | ` test_array ` | Not ported | Easy |
51+ | ` test_bigint ` | Not ported | Easy |
52+ | ` test_cannot_run_js ` | Not ported | Medium |
53+ | ` test_constructor ` | Not ported | Medium |
54+ | ` test_conversions ` | Not ported | Medium |
55+ | ` test_dataview ` | Not ported | Easy |
56+ | ` test_date ` | Not ported | Easy |
57+ | ` test_error ` | Not ported | Medium |
58+ | ` test_exception ` | Not ported | Medium |
59+ | ` test_finalizer ` | Not ported | Medium |
60+ | ` test_function ` | Not ported | Medium |
61+ | ` test_general ` | Not ported | Hard |
62+ | ` test_handle_scope ` | Not ported | Easy |
63+ | ` test_instance_data ` | Not ported | Easy |
64+ | ` test_new_target ` | Not ported | Easy |
65+ | ` test_number ` | Not ported | Easy |
66+ | ` test_object ` | Not ported | Hard |
67+ | ` test_promise ` | Not ported | Easy |
68+ | ` test_properties ` | Not ported | Easy |
69+ | ` test_reference ` | Not ported | Medium |
70+ | ` test_reference_double_free ` | Not ported | Easy |
71+ | ` test_sharedarraybuffer ` | Not ported | Medium |
72+ | ` test_string ` | Not ported | Medium |
73+ | ` test_symbol ` | Not ported | Easy |
74+ | ` test_typedarray ` | Not ported | Medium |
7475
7576## Runtime-specific (` node-api ` )
7677
7778Tests covering the runtime-specific part of Node-API, defined in ` node_api.h ` .
7879
79- | Directory | Status | Difficulty |
80- | ---| ---| ---|
81- | ` 1_hello_world ` | Not ported | Easy |
82- | ` test_async ` | Not ported | Hard |
83- | ` test_async_cleanup_hook ` | Not ported | Hard |
84- | ` test_async_context ` | Not ported | Hard |
85- | ` test_buffer ` | Not ported | Medium |
86- | ` test_callback_scope ` | Not ported | Hard |
87- | ` test_cleanup_hook ` | Not ported | Medium |
88- | ` test_env_teardown_gc ` | Not ported | Easy |
89- | ` test_exception ` | Not ported | Easy |
90- | ` test_fatal ` | Not ported | Hard |
91- | ` test_fatal_exception ` | Not ported | Easy |
92- | ` test_general ` | Not ported | Medium |
93- | ` test_init_order ` | Not ported | Medium |
94- | ` test_instance_data ` | Not ported | Hard |
95- | ` test_make_callback ` | Not ported | Hard |
96- | ` test_make_callback_recurse ` | Not ported | Hard |
97- | ` test_null_init ` | Not ported | Medium |
98- | ` test_reference_by_node_api_version ` | Not ported | Medium |
99- | ` test_sea_addon ` | Not ported | Hard |
100- | ` test_threadsafe_function ` | Not ported | Hard |
101- | ` test_threadsafe_function_shutdown ` | Not ported | Hard |
102- | ` test_uv_loop ` | Not ported | Hard |
103- | ` test_uv_threadpool_size ` | Not ported | Hard |
104- | ` test_worker_buffer_callback ` | Not ported | Hard |
105- | ` test_worker_terminate ` | Not ported | Hard |
106- | ` test_worker_terminate_finalization ` | Not ported | Hard |
80+ | Directory | Status | Difficulty |
81+ | ------------------------------------ | ---------- | ---------- |
82+ | ` 1_hello_world ` | Not ported | Easy |
83+ | ` test_async ` | Not ported | Hard |
84+ | ` test_async_cleanup_hook ` | Not ported | Hard |
85+ | ` test_async_context ` | Not ported | Hard |
86+ | ` test_buffer ` | Not ported | Medium |
87+ | ` test_callback_scope ` | Not ported | Hard |
88+ | ` test_cleanup_hook ` | Not ported | Medium |
89+ | ` test_env_teardown_gc ` | Not ported | Easy |
90+ | ` test_exception ` | Not ported | Easy |
91+ | ` test_fatal ` | Not ported | Hard |
92+ | ` test_fatal_exception ` | Not ported | Easy |
93+ | ` test_general ` | Not ported | Medium |
94+ | ` test_init_order ` | Not ported | Medium |
95+ | ` test_instance_data ` | Not ported | Hard |
96+ | ` test_make_callback ` | Not ported | Hard |
97+ | ` test_make_callback_recurse ` | Not ported | Hard |
98+ | ` test_null_init ` | Not ported | Medium |
99+ | ` test_reference_by_node_api_version ` | Not ported | Medium |
100+ | ` test_sea_addon ` | Not ported | Hard |
101+ | ` test_threadsafe_function ` | Not ported | Hard |
102+ | ` test_threadsafe_function_shutdown ` | Not ported | Hard |
103+ | ` test_uv_loop ` | Not ported | Hard |
104+ | ` test_uv_threadpool_size ` | Not ported | Hard |
105+ | ` test_worker_buffer_callback ` | Not ported | Hard |
106+ | ` test_worker_terminate ` | Not ported | Hard |
107+ | ` test_worker_terminate_finalization ` | Not ported | Hard |
108+
109+ ## Experimental Node-API Features
110+
111+ Several tests in the upstream Node.js repository use experimental APIs that are guarded behind
112+ ` #ifdef NAPI_EXPERIMENTAL ` in Node.js's ` js_native_api.h ` .
113+
114+ When ` NAPI_EXPERIMENTAL ` is defined in Node.js, ` NAPI_VERSION ` is set to
115+ ` NAPI_VERSION_EXPERIMENTAL (2147483647) ` . The ` NAPI_MODULE ` macro exports this version, and the
116+ runtime uses it to decide whether to enable experimental behavior for that addon.
117+
118+ | Feature macro | APIs | Used by |
119+ | --------------------------------------------------------- | -------------------------------------------------------------------- | ------------------------------------------------- |
120+ | ` NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER ` | ` node_api_is_sharedarraybuffer ` , ` node_api_create_sharedarraybuffer ` | ` test_dataview ` , ` test_sharedarraybuffer ` |
121+ | ` NODE_API_EXPERIMENTAL_HAS_CREATE_OBJECT_WITH_PROPERTIES ` | ` node_api_create_object_with_properties ` | ` test_object ` |
122+ | ` NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE ` | ` node_api_set_prototype ` | ` test_general ` |
123+ | ` NODE_API_EXPERIMENTAL_HAS_POST_FINALIZER ` | ` node_api_post_finalizer ` | ` test_general ` , ` test_finalizer ` , ` 6_object_wrap ` |
124+
125+ Tests that depend on these APIs are currently ported without the experimental test cases (marked
126+ as "Partial" in the status column) or not ported at all.
127+
128+ ### Infrastructure for experimental features
129+
130+ The CTS provides the following infrastructure (see [ #26 ] ( https://github.com/nodejs/node-api-cts/issues/26 ) ):
131+
132+ 1 . ** Vendored headers** — The ` include/ ` directory contains Node-API headers vendored directly from
133+ the Node.js repository (updated via ` npm run update-headers ` ). These include experimental API
134+ declarations behind ` #ifdef NAPI_EXPERIMENTAL ` .
135+
136+ 2 . ** CMake build function** — ` add_node_api_cts_experimental_addon() ` compiles an addon with
137+ ` NAPI_EXPERIMENTAL ` defined, enabling all experimental API declarations and setting
138+ ` NAPI_VERSION ` to ` NAPI_VERSION_EXPERIMENTAL ` (2147483647).
139+
140+ 3 . ** Implementor feature declaration** — Each runtime provides a ` features.js ` harness module that
141+ sets ` globalThis.experimentalFeatures ` to an object declaring which experimental features it
142+ supports (e.g., ` { sharedArrayBuffer: true, postFinalizer: true } ` ).
143+
144+ 4 . ** Conditional test execution** — JS test files guard experimental assertions behind feature
145+ checks. When a feature is unsupported, the guarded code silently does not execute.
146+
147+ ``` js
148+ if (experimentalFeatures .sharedArrayBuffer ) {
149+ const addon = loadAddon (" test_sharedarraybuffer" );
150+ // ... assertions
151+ }
152+ ```
153+
154+ The ` loadAddon ` call must be inside the guard because addons linked against experimental
155+ symbols will fail to load on runtimes that don't export those symbols.
107156
108157## Special Considerations
109158
@@ -144,6 +193,7 @@ The following tests call into libuv directly — `napi_get_uv_event_loop`, `uv_t
144193- ` test_uv_loop ` , ` test_uv_threadpool_size `
145194
146195Porting options:
196+
1471971 . ** Node-only scope** — mark these tests as Node.js-only and skip on other runtimes.
1481982 . ** Harness abstraction** — introduce a minimal platform-agnostic threading/async API in the
149199 harness (e.g., ` cts_thread_create ` , ` cts_async_schedule ` ) that implementors back with their
0 commit comments