Skip to content

[Feature] Add unit tests for StartNetworkInspector and StopNetworkInspector command classes #2656

@ConnorQi01

Description

@ConnorQi01

Summary

StartNetworkInspector and StopNetworkInspector in src/extension/commands/networkInspector.ts have no unit tests. The module-level singleton inspectorManager means the "already running" early-return branch in StartNetworkInspector.baseFn is never exercised by any test, and the StopNetworkInspector delegation path is also untested at the command level.

Why this is useful

NetworkInspectorManager lifecycle is now well-covered (#2637), but the command classes that wrap it — including the guard logic and logger call — are not. Adding tests here closes the gap between manager-level and command-level coverage, and makes future changes to the guard or error handling safer to refactor.

Suggested scope

  • Add test/extension/networkInspector/networkInspector.test.ts using proxyquire to inject a fake NetworkInspectorManager
  • Cover: StartNetworkInspector calls manager.start when not running; logs and returns early when isRunning() is true; StopNetworkInspector always calls manager.stop

Evidence

  • src/extension/commands/networkInspector.ts:19 — module-level singleton, not injectable without proxyquire
  • src/extension/commands/networkInspector.ts:32-38isRunning() guard branch has no test coverage
  • test/extension/networkInspector/ — contains networkInspectorManager.test.ts but no command-level test file
  • Recent PR Add Network Inspector manager lifecycle tests #2637 added manager lifecycle tests, leaving command-class tests as the remaining gap

Validation

  • Run npm test and confirm the new suite passes
  • Verify the "already running" log message branch is exercised

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