Skip to content

[Feature] Add unit tests for RunEasBuild command #2840

Description

@ConnorQi01

Summary

The RunEasBuild command (src/extension/commands/runEasBuild.ts) has no unit test coverage. It contains conditional file-creation logic that is worth validating: it creates eas.json when absent, creates .eas/workflows/create-production-builds.yml when absent, and shows error messages on file-system permission failures. None of this logic is currently exercised by any test.

Why this is useful

Unit tests will catch regressions in the file-creation and permission-error paths without requiring a real EAS project, keeping CI reliable as the command evolves alongside the EAS workflow feature.

Suggested scope

  • Mock the file system (fs.existsSync, fs.writeFileSync, fs.mkdirSync) and vscode.window.showErrorMessage using proxyquire + Sinon, following the same pattern as launchAndroidEmulator.test.ts
  • Test case: project root path is undefined → error message shown, no file created
  • Test case: eas.json already exists → file write skipped
  • Test case: eas.json missing → file created with {}
  • Test case: workflow file already exists → mkdirSync/writeFileSync skipped
  • Test case: workflow file missing → directory and file created with expected YAML template
  • Test case: fs.writeFileSync throws (permission error) → error message shown

Evidence

Validation

  • Run npm test (or the mocha suite for test/extension/commands/) and confirm the new test file passes
  • Confirm no regressions in the existing command test suite

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