You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The StopPackager command has two distinct code paths in onBeforeExecute and an optional-chaining call in baseFn that are not covered by any unit tests, while its symmetric counterpart StartPackager received full unit test coverage in PR #2756.
Why this is useful
Adds deterministic coverage for the packager stop lifecycle, ensuring both the direct-AppLauncher path and the selectProject() fallback behave correctly; also explicitly validates the no-op case when getPackager() returns undefined.
Suggested scope
Test onBeforeExecute when called with an AppLauncher instance (should assign directly without calling selectProject)
Test onBeforeExecute when called with a non-AppLauncher argument (should call selectProject)
Test baseFn when getPackager() returns a real packager (should call stop())
Test baseFn when getPackager() returns undefined (should not throw due to optional chaining)
Follow the proxyquire/sinon pattern established in test/extension/commands/startPackager.test.ts
Evidence
src/extension/commands/stopPackager.ts: two branches in onBeforeExecute (lines 18–25), optional-chain call getPackager()?.stop() in baseFn (line 30)
Summary
The
StopPackagercommand has two distinct code paths inonBeforeExecuteand an optional-chaining call inbaseFnthat are not covered by any unit tests, while its symmetric counterpartStartPackagerreceived full unit test coverage in PR #2756.Why this is useful
Adds deterministic coverage for the packager stop lifecycle, ensuring both the direct-
AppLauncherpath and theselectProject()fallback behave correctly; also explicitly validates the no-op case whengetPackager()returnsundefined.Suggested scope
onBeforeExecutewhen called with anAppLauncherinstance (should assign directly without callingselectProject)onBeforeExecutewhen called with a non-AppLauncherargument (should callselectProject)baseFnwhengetPackager()returns a real packager (should callstop())baseFnwhengetPackager()returnsundefined(should not throw due to optional chaining)test/extension/commands/startPackager.test.tsEvidence
src/extension/commands/stopPackager.ts: two branches inonBeforeExecute(lines 18–25), optional-chain callgetPackager()?.stop()inbaseFn(line 30)test/extension/commands/startPackager.test.ts: reference pattern for the sister command, merged in PR Add StartPackager branch tests #2756test/extension/commands/stopPackager.test.tsgh issue listValidation
npm testpasses with the new test file included