test: compare DOM nodes by identity, never through assert.equal

A failed assert.equal or deepEqual prints both operands, and a happy-dom
node reaches the whole page and window: printing one exhausted memory and
took the machine down. assertSameNode() compares identity and fails with
a short description of each node; every node comparison in the happy-dom
tests uses it.
This commit is contained in:
Sameh Khamis committed 2026-10-30 20:38:29 -07:00
1 parent e949584c0a
commit 3a2acf9b0f
8 files changed
+46 -20

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { assertSameNode } from '../testSupport/domAssert.mjs';
import { nextTick } from 'vue';
import { createRailTimeline } from './railTimeline.js';
import { railDocumentFixture as railFixture } from './railTestFixture.mjs';
@@ -46,8 +47,8 @@ test('preview is immediate, commits are coalesced and the drag DOM and tick mapp
index: 1,
readout: 'Refresh',
});
assert.equal(slider.parentElement, row);
assert.equal(row.children[1], slider);
assertSameNode(slider.parentElement, row);
assertSameNode(row.children[1], slider);
assert.equal(slider.value, '0');
assert.equal(slider.max, '2');
assert.equal(