Skip to content

[BUG-34] withHookContext error swallowing makes hook tests pass vacuously #45

Description

@shroy

Severity: P0 (test integrity — systemic) · Batch: B1 (test-integrity + CI)

Location

src/core/hookContext.js:170-183: withHookContext catches everythinglogger.errorreturn null

Root cause

Seven spec files (useEvents/useClasses/useAttributes/useStyles/useText/signalEffect/nonSignalWarning) place expect() assertions inside withHookContext(...) callbacks — a thrown AssertionError is eaten by the framework and the test passes.

Proof

src/tests/useEvents.spec.js:216-242 asserts addEventListener receives raw handler1 and that signal handlers fire — both demonstrably false in the current implementation (BUG-1), yet the suite is green.

Proposed fix

In tests, assert outside the callback or capture results; better, make withHookContext rethrow unknown errors in a test/debug mode. Re-run the whole suite after fixing — expect real failures to surface.

Verification recipe

Spec: withHookContext(el, () => { expect(true).toBe(false) }) followed by an outside assertion that the callback's failure surfaced — demonstrate it returns null and the test framework saw no failure. Expected on unmodified code: swallowed → confirmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions