Skip to content

[Feature] Add direct unit tests for DebuggerEndpointHelper #2705

@ConnorQi01

Description

@ConnorQi01

Summary

DebuggerEndpointHelper has important endpoint selection and fallback logic, but it is currently covered only indirectly through reactNativeCDPProxy.test.ts. Direct unit tests would make regressions easier to catch without requiring a live CDP proxy server.

Why this is useful

The helper is used by both ReactNativeCDPProxy and direct debugging flows. It handles /json/version vs /json/list fallback, Hermes improved Chrome reload target selection, debugger type detection, retry behavior, and loopback HTTPS certificate handling. A small direct test suite can exercise these branches with stubbed HTTP/HTTPS/DNS dependencies.

Suggested scope

  • Add direct tests for src/cdp-proxy/debuggerEndpointHelper.ts.
  • Cover getWSEndpoint returning /json/version webSocketDebuggerUrl when present.
  • Cover fallback to /json/list, including the Hermes "React Native Experimental (Improved Chrome Reloads)" target selection.
  • Cover fallback to the default Metro http://localhost:8081/json/list endpoint when the requested browser URL has no targets.
  • Cover getDebuggerTpye returning expo vs react-native from title/description data.
  • Cover retry/cancellation behavior in retryGetWSEndpoint without waiting on real network services.

Evidence

  • test/cdp-proxy/reactNativeCDPProxy.test.ts calls new DebuggerEndpointHelper().getWSEndpoint(...), but only as part of proxy setup.
  • There is no direct debuggerEndpointHelper test file under test/cdp-proxy/.
  • src/cdp-proxy/debuggerEndpointHelper.ts contains multiple fallback/error branches that are not explicitly asserted.

Validation

  • npm test should include the new helper tests and pass.
  • The tests should not require a real Metro server, device, or browser target.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions