Summary
The CleanRestartPackager command (src/extension/commands/cleanRestartPackager.ts) has no dedicated unit tests. It implements a 4-step flow (kill Metro port, clean Metro cache, clean Watchman cache, restart packager) with platform-specific branching (Windows vs macOS/Linux), but test/extension/commands/ only contains commands.test.ts and installPods.test.ts.
Why this is useful
Without unit tests, regressions in any of the four steps — especially the platform-specific killMetroProcess logic or the deleteDirectory recursion — go undetected until a user reports a broken "Clean & Restart Packager" command. Adding tests brings this command to the same coverage level as installPods.
Suggested scope
- Add
test/extension/commands/cleanRestartPackager.test.ts using proxyquire or sinon stubs to mock ChildProcess, fs, and ProjectVersionHelper
- Cover: Windows path (netstat/taskkill), macOS/Linux path (lsof/kill), Metro cache absent, Watchman unavailable, and error-tolerant paths
- No smoke test needed; unit coverage is sufficient for this command
Evidence
src/extension/commands/cleanRestartPackager.ts — 152 lines, 4 private methods, platform branching at line 58
test/extension/commands/ — only commands.test.ts and installPods.test.ts exist (no coverage for this command)
installPods.test.ts provides a direct pattern to follow for command-level unit tests
Validation
- Run
npm test (unit suite) and confirm the new test file is picked up and passes
- Verify Windows and non-Windows branches are both exercised via mocked
HostPlatform.getPlatformId()
Summary
The
CleanRestartPackagercommand (src/extension/commands/cleanRestartPackager.ts) has no dedicated unit tests. It implements a 4-step flow (kill Metro port, clean Metro cache, clean Watchman cache, restart packager) with platform-specific branching (Windows vs macOS/Linux), buttest/extension/commands/only containscommands.test.tsandinstallPods.test.ts.Why this is useful
Without unit tests, regressions in any of the four steps — especially the platform-specific
killMetroProcesslogic or thedeleteDirectoryrecursion — go undetected until a user reports a broken "Clean & Restart Packager" command. Adding tests brings this command to the same coverage level asinstallPods.Suggested scope
test/extension/commands/cleanRestartPackager.test.tsusingproxyquireor sinon stubs to mockChildProcess,fs, andProjectVersionHelperEvidence
src/extension/commands/cleanRestartPackager.ts— 152 lines, 4 private methods, platform branching at line 58test/extension/commands/— onlycommands.test.tsandinstallPods.test.tsexist (no coverage for this command)installPods.test.tsprovides a direct pattern to follow for command-level unit testsValidation
npm test(unit suite) and confirm the new test file is picked up and passesHostPlatform.getPlatformId()