Skip to content

[Feature] Add unit tests for RunExponent command flow #2886

Description

@ConnorQi01

Summary

The RunExponent command (src/extension/commands/runExponent.ts) has no unit test coverage. It is the only Run* command without a dedicated test file, while RunAndroid, RunIOS, RunEasBuild, and RunMacOS/RunWindows (tracked in #2882) already have or are getting tests.

Why this is useful

Unit tests for RunExponent will catch regressions in the Expo packager startup flow and the login step (onBeforeExecute) before they reach users. The command has two distinct code paths that benefit from isolation testing: the packager lifecycle (beforeStartPackagerstartPackager) and the Expo login fallback on error.

Suggested scope

  • Mock ProjectVersionHelper.getReactNativePackageVersionsFromNodeModules, ExponentPlatform, loginToExponent, and ReactNativeCommand base class using the same proxyquire / Sinon pattern used in runAndroid.test.ts and runIos.test.ts.
  • Cover the happy path: version resolution → ExponentPlatform constructor called with correct PlatformType.ExponentbeforeStartPackagerstartPackager.
  • Cover onBeforeExecute: loginToExponent is called; verify that a login failure propagates as a rejection.
  • Verify that setReactNativeVersions is called with the resolved versions.

Evidence

Validation

  • npm run test passes with the new test file.
  • Test suite reports coverage for runExponent.ts baseFn and onBeforeExecute branches.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions