From 7372d12088ec7d559a60ac8cb35fd82aaff8c098 Mon Sep 17 00:00:00 2001 From: znetsixe Date: Sun, 10 May 2026 19:32:31 +0200 Subject: [PATCH] fix(BaseNodeAdapter test): close intervals to unblock batch test runs Tests 1, 4, 5 constructed an Adapter with the default statusInterval=1000 and no mock for setInterval, leaking a real status timer that held the event loop open past the assertions. Single-file runs masked it; node --test test/basic/ blocked the whole runner. Fix: set static statusInterval = 0 + invoke node.handlers.close() (or mock setInterval where the test asserts on registration timing). 113/113 basic tests pass in batch in ~400 ms. Co-Authored-By: Claude Opus 4.7 (1M context) --- test/basic/BaseNodeAdapter.basic.test.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/basic/BaseNodeAdapter.basic.test.js b/test/basic/BaseNodeAdapter.basic.test.js index 808d141..061dea6 100644 --- a/test/basic/BaseNodeAdapter.basic.test.js +++ b/test/basic/BaseNodeAdapter.basic.test.js @@ -79,6 +79,9 @@ test('full subclass constructs and stores wiring on this', () => { class Adapter extends BaseNodeAdapter { static DomainClass = Domain; static commands = []; + // Disable the real status interval — would hold the event loop open + // past the test and stall `node --test test/basic/` runs. + static statusInterval = 0; buildDomainConfig() { return { extra: { foo: 1 } }; } } const node = makeNode(); @@ -88,6 +91,7 @@ test('full subclass constructs and stores wiring on this', () => { assert.equal(node.source, a.source); assert.equal(a.config.extra.foo, 1); assert.equal(a.config.general.name, 'm1'); + node.handlers.close(() => {}); }); // ---- 2-4. Static-field validation ----------------------------------------- @@ -122,17 +126,20 @@ test('static commands = [] is allowed (explicit no-op registry)', () => { class Adapter extends BaseNodeAdapter { static DomainClass = makeDomain(); static commands = []; + static statusInterval = 0; // see fix in test #1 buildDomainConfig() { return {}; } } + const node = makeNode(); assert.doesNotThrow( - () => new Adapter({}, makeRED(), makeNode(), 'measurement'), + () => new Adapter(uiConfigFixture(), makeRED(), node, 'measurement'), ); + node.handlers.close(() => {}); }); // ---- 5. Registration message after 100 ms --------------------------------- test('registration message fires on Port 2 after 100 ms with child.register', (t) => { - t.mock.timers.enable({ apis: ['setTimeout'] }); + t.mock.timers.enable({ apis: ['setTimeout', 'setInterval'] }); class Adapter extends BaseNodeAdapter { static DomainClass = makeDomain(); static commands = [];