Skip to content

[Feature] Add unit tests for NetworkInspectorManager start/stop lifecycle #2749

Description

@ConnorQi01

Summary

NetworkInspectorManager has meaningful branching logic — startup rollback on failure, conditional iOS tracker creation on non-macOS, duplicate-start guard, and silent no-op stop — but no unit tests cover any of it.

Why this is useful

The class manages a multi-component lifecycle (AdbHelper, AndroidDeviceTracker, IOSDeviceTracker, NetworkInspectorServer) and its rollback path is easy to silently regress. Tests give contributors confidence when modifying startup or teardown logic and align with the recent pattern of adding focused unit tests for command-level branching (setNewArch, StartPackager, enableExpoHermes).

Suggested scope

  • Test isRunning() returns false before start, true after start, false after stop
  • Test start() throws when already running
  • Test start() rolls back (calls stop()) when one of the inner components throws during startup
  • Test stop() is a no-op when not running
  • Test StartNetworkInspector.baseFn() logs and returns early when isRunning() is true, without calling start()

Evidence

  • src/extension/commands/networkInspectorManager.ts — rollback path in start() catch block (line 62–64), conditional iOS tracker (line 43)
  • src/extension/commands/networkInspector.ts — early-return guard in StartNetworkInspector.baseFn() (line 32–39)
  • No file under test/extension/commands/ covers NetworkInspector or NetworkInspectorManager
  • Pattern to follow: test/extension/commands/setNewArch.test.ts, test/extension/commands/cleanRestartPackager.test.ts

Validation

  • npm test passes with the new test file included
  • Coverage over start(), stop(), and isRunning() branches confirmed

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