Skip to content

[Feature] Add unit tests for StartPackager stop-and-restart branching logic #2746

Description

@ConnorQi01

Summary

StartPackager.baseFn() has a meaningful branch: if the packager is already running, it stops it before starting. This stop-and-restart path is currently not covered by any unit test, leaving a regression risk for the core packager start workflow.

Why this is useful

The start-packager command is one of the most frequently used commands. Without tests, a future change to Packager.isRunning() integration or the stop-then-start sequence could silently break the behavior. Adding tests would match the coverage pattern already established for cleanRestartPackager, stopPackager, and killPort.

Suggested scope

  • Test the path where isRunning() returns false: verify only start() is called, never stop()
  • Test the path where isRunning() returns true: verify stop() is called before start()
  • Use proxyquire + sinon stubs, consistent with cleanRestartPackager.test.ts
  • Add the test file as test/extension/commands/startPackager.test.ts

Evidence

  • Source: src/extension/commands/startPackager.ts — contains the isRunning → stop → start branch
  • Pattern reference: test/extension/commands/cleanRestartPackager.test.ts shows the established mock structure for testing packager command branching
  • No existing test file for startPackager in test/extension/commands/

Validation

  • Run npm test / mocha unit suite and confirm both new test cases pass
  • Confirm no regression in the existing packager command tests

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