MCPcopy Index your code
hub / github.com/nodejs/node / runAsyncTests

Function runAsyncTests

test/js-native-api/test_finalizer/test.js:31–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29// The finalizer that access JS cannot run synchronously. They are run in the
30// next JS loop tick. Thus, we must use gcUntil.
31async function runAsyncTests() {
32 // We do not use common.mustCall() because we want to see the finalizer
33 // called in response to GC and not as a part of env destruction.
34 let js_is_called = false;
35 // We use IIFE for the obj scope instead of {} to be compatible with
36 // non-V8 JS engines that do not support scoped variables.
37 (() => {
38 const obj = {};
39 test_finalizer.addFinalizerWithJS(obj, () => { js_is_called = true; });
40 })();
41 await gcUntil('ensure JS finalizer called',
42 () => (test_finalizer.getFinalizerCallCount() === 2));
43 assert(js_is_called);
44}
45runAsyncTests();

Callers 1

test.jsFile · 0.85

Calls 2

gcUntilFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…