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
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 forcleanRestartPackager,stopPackager, andkillPort.Suggested scope
isRunning()returnsfalse: verify onlystart()is called, neverstop()isRunning()returnstrue: verifystop()is called beforestart()proxyquire+ sinon stubs, consistent withcleanRestartPackager.test.tstest/extension/commands/startPackager.test.tsEvidence
src/extension/commands/startPackager.ts— contains theisRunning → stop → startbranchtest/extension/commands/cleanRestartPackager.test.tsshows the established mock structure for testing packager command branchingstartPackagerintest/extension/commands/Validation
npm test/ mocha unit suite and confirm both new test cases pass