Summary
The RestartPackager command (src/extension/commands/restartPackager.ts) has no dedicated unit tests. It calls ProjectVersionHelper.getReactNativePackageVersionsFromNodeModules as a version check before invoking packager.restart(port), but neither the success path nor the failure path is currently exercised in the test suite.
Why this is useful
CleanRestartPackager — the sibling command that performs the same restart step plus extra cleanup — already has comprehensive unit tests following the proxyquire + sinon pattern. Adding equivalent coverage for RestartPackager closes a visible gap in the packager command family and makes regressions on the version-check/restart flow detectable before release.
Suggested scope
- Add
test/extension/commands/restartPackager.test.ts following the same proxyquire pattern used in cleanRestartPackager.test.ts
- Test: happy path — version check resolves, packager restarts with the port returned by
SettingsHelper.getPackagerPort
- Test: version check rejects — error propagates and
packager.restart is not called
- Test: correct port value is forwarded to
packager.restart
Evidence
src/extension/commands/restartPackager.ts — calls ProjectVersionHelper.getReactNativePackageVersionsFromNodeModules(nodeModulesRoot) then packager.restart(port)
test/extension/commands/cleanRestartPackager.test.ts — established proxyquire + sinon pattern ready to reuse
test/extension/commands/ directory — sibling commands (killPort, installPods, startPackager, etc.) all have dedicated test files; restartPackager is the only packager-related command without one
Validation
- Run
npm test (or the mocha suite for test/extension/commands/) and confirm the new test file passes
- Confirm no regression in existing packager command tests
Summary
The
RestartPackagercommand (src/extension/commands/restartPackager.ts) has no dedicated unit tests. It callsProjectVersionHelper.getReactNativePackageVersionsFromNodeModulesas a version check before invokingpackager.restart(port), but neither the success path nor the failure path is currently exercised in the test suite.Why this is useful
CleanRestartPackager— the sibling command that performs the same restart step plus extra cleanup — already has comprehensive unit tests following the proxyquire + sinon pattern. Adding equivalent coverage forRestartPackagercloses a visible gap in the packager command family and makes regressions on the version-check/restart flow detectable before release.Suggested scope
test/extension/commands/restartPackager.test.tsfollowing the same proxyquire pattern used incleanRestartPackager.test.tsSettingsHelper.getPackagerPortpackager.restartis not calledpackager.restartEvidence
src/extension/commands/restartPackager.ts— callsProjectVersionHelper.getReactNativePackageVersionsFromNodeModules(nodeModulesRoot)thenpackager.restart(port)test/extension/commands/cleanRestartPackager.test.ts— established proxyquire + sinon pattern ready to reusetest/extension/commands/directory — sibling commands (killPort, installPods, startPackager, etc.) all have dedicated test files;restartPackageris the only packager-related command without oneValidation
npm test(or the mocha suite fortest/extension/commands/) and confirm the new test file passes