LearnNewsExamplesServices
Frontmatter
id8876
titletest: Fix Namespace Collisions in Unit Tests exposed by setupClass Guardrail
stateClosed
labels
refactoringtestingcore
assigneestobiu
createdAtJan 24, 2026, 3:25 PM
updatedAtJan 24, 2026, 4:26 PM
githubUrlhttps://github.com/neomjs/neo/issues/8876
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 24, 2026, 3:47 PM

test: Fix Namespace Collisions in Unit Tests exposed by setupClass Guardrail

Closed v11.24.0 refactoringtestingcore
tobiu
tobiu commented on Jan 24, 2026, 3:25 PM

Description: We recently hardened Neo.setupClass to throw an error when Neo.config.unitTestMode is true and a namespace collision occurs. This prevents test isolation issues where different tests unintentionally share or overwrite class definitions.

This change has exposed existing collisions in our test suite, where multiple test files define classes with generic names like Mock.Component or Test.Container.

Goals:

  1. Enforce Unique ClassNames: Update all failing tests to use unique, file-specific class names (e.g., Test.Unit.Vdom.TreeBuilder.MockComponent).
  2. Verify Stability: Ensure the entire Playwright unit test suite passes with the new guardrail in place.

Known Failures:

  • test/playwright/unit/state/ProviderNestedDataConfigs.spec.mjs (Mock.Component)
  • test/playwright/unit/vdom/TreeBuilder.spec.mjs (Test.MockComponent)
  • test/playwright/unit/vdom/VdomLifecycle.spec.mjs (Test.MockComponent)
  • test/playwright/unit/vdom/VdomMerging.spec.mjs (Test.Container)

Action Plan: Iterate through the failing tests and rename the test classes to be unique.

tobiu added the refactoring label on Jan 24, 2026, 3:25 PM
tobiu added the testing label on Jan 24, 2026, 3:25 PM
tobiu added the core label on Jan 24, 2026, 3:25 PM
tobiu referenced in commit 350770c - "test: Fix Namespace Collisions in Unit Tests exposed by setupClass Guardrail (#8876)" on Jan 24, 2026, 3:45 PM
tobiu assigned to @tobiu on Jan 24, 2026, 3:46 PM
tobiu
tobiu Jan 24, 2026, 3:46 PM

Input from Gemini 3 Pro:

✦ I have resolved the namespace collisions in the unit test suite and enabled the new setupClass guardrail.

Implementation Details:

  1. Hardened Neo.setupClass: Modified src/Neo.mjs to throw a specific error (Namespace collision in unitTestMode) when a namespace is redefined while Neo.config.unitTestMode is true. This ensures strict isolation for unit tests.
  2. Fixed Test Suite Collisions: I identified and renamed colliding class definitions in the following test files to be unique and file-specific:
    • test/playwright/unit/state/ProviderNestedDataConfigs.spec.mjs: Mock.Component -> Test.Unit.State.ProviderNestedDataConfigs.MockComponent
    • test/playwright/unit/vdom/TreeBuilder.spec.mjs: Test.MockComponent -> Test.Unit.Vdom.TreeBuilder.MockComponent
    • test/playwright/unit/vdom/VdomLifecycle.spec.mjs: Test.MockComponent -> Test.Unit.Vdom.VdomLifecycle.MockComponent
    • test/playwright/unit/vdom/VdomMerging.spec.mjs: Test.Container -> Test.Unit.Vdom.VdomMerging.Container
    • test/playwright/unit/core/ClassConfigsAndFields.spec.mjs: Neo.TestClass -> Test.Unit.Core.ClassConfigsAndFields.TestClass and fixed Neo.core.Base collision.
    • test/playwright/unit/core/ClassSystem.spec.mjs: Neo.TestClass -> Test.Unit.Core.ClassSystem.TestClass

Note: The setupClass change is being committed NOW as part of this PR, effectively activating the guardrail for all future test runs.

The full unit test suite now passes with strict namespace enforcement enabled.

tobiu closed this issue on Jan 24, 2026, 3:47 PM