Skip to content

[Feature] Add unit tests for ScriptImporter URL construction and debugger worker URL logic #2716

@ConnorQi01

Description

@ConnorQi01

Summary

ScriptImporter is a core debugger component with no dedicated unit tests. It contains pure URL construction and manipulation methods that have version-dependent branching, making them good targets for focused unit tests.

Why this is useful

The prepareDebuggerWorkerURL and overridePackagerPort methods drive how the debugger connects to Metro. A bug in URL construction (wrong port, missing debugger-ui/ path for RN ≥ 0.50, wrong path for custom debuggerWorkerUrlPath) silently breaks debugging sessions. Unit tests would catch regressions here without requiring a full integration run.

Suggested scope

  • Add test/debugger/scriptImporter.test.ts
  • Test prepareDebuggerWorkerURL for RN < 0.50, RN ≥ 0.50, canary versions, and explicit debuggerWorkerUrlPath override
  • Test overridePackagerPort with localhost URLs to verify port replacement without breaking query strings
  • No need to test async I/O methods (downloadAppScript, downloadDebuggerWorker) in this issue

Evidence

Validation

  • npm test passes with new test cases
  • Test covers all three branches of prepareDebuggerWorkerURL

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