LearnNewsExamplesServices
Frontmatter
id8830
titleStabilize VDOM Unit Tests: Eliminate ID Collisions in Parallel Execution
stateClosed
labels
airefactoringtesting
assigneestobiu
createdAtJan 20, 2026, 5:12 PM
updatedAtJan 20, 2026, 5:18 PM
githubUrlhttps://github.com/neomjs/neo/issues/8830
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 20, 2026, 5:18 PM

Stabilize VDOM Unit Tests: Eliminate ID Collisions in Parallel Execution

Closed v11.23.0 airefactoringtesting
tobiu
tobiu commented on Jan 20, 2026, 5:12 PM

This ticket addresses the instability of the VDOM unit test suite when running with multiple workers (parallel execution).

The Problem: Running npm run test-unit resulted in sporadic failures and numerous [Base.mjs] Trying to create an item with an already existing id errors. This was caused by several test files (specifically RaceCondition.spec.mjs and TreeBuilder.spec.mjs) using hardcoded component IDs (e.g., 'child-1', 'test-container'). When Playwright executed these tests in parallel or reused workers without perfect cleanup, these IDs collided, leading to cross-test pollution and failures.

The Solution: Refactor the affected test files to use dynamic, unique IDs for all components created during testing.

  • Introduced a helper function to generate unique IDs (e.g., ${prefix}-${timestamp}-${counter}).
  • Updated RaceCondition.spec.mjs and TreeBuilder.spec.mjs to use these dynamic IDs.
  • Ensured proper cleanup of dynamically created components in test.afterEach.

Outcome: The full unit test suite now passes consistently with 8 workers, with no ID collision errors.

tobiu added the ai label on Jan 20, 2026, 5:12 PM
tobiu added the refactoring label on Jan 20, 2026, 5:12 PM
tobiu added the testing label on Jan 20, 2026, 5:12 PM
tobiu referenced in commit 5c3ca3b - "test: Stabilize VDOM Unit Tests: Eliminate ID Collisions in Parallel Execution (#8830)" on Jan 20, 2026, 5:17 PM
tobiu assigned to @tobiu on Jan 20, 2026, 5:17 PM
tobiu
tobiu Jan 20, 2026, 5:17 PM

Input from Gemini 3 Pro:

✦ I have refactored RaceCondition.spec.mjs and TreeBuilder.spec.mjs to use dynamic, unique IDs for all test components.

Changes:

  • Implemented a getUniqueId helper in test files.
  • Replaced hardcoded IDs (e.g., 'child-1') with generated ones (e.g., 'child-1-1705...').
  • Updated teardown logic to track and destroy these dynamically named components.

Verification: npm run test-unit now passes 240/240 tests consistently with 8 workers, and the ID collision errors are gone.

tobiu closed this issue on Jan 20, 2026, 5:18 PM