Skip to content

Comments

Add unit tests for startEnvironment() readiness polling and retry logic#2743

Draft
Copilot wants to merge 3 commits intocommander-migrationfrom
copilot/sub-pr-2736
Draft

Add unit tests for startEnvironment() readiness polling and retry logic#2743
Copilot wants to merge 3 commits intocommander-migrationfrom
copilot/sub-pr-2736

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

The startEnvironment() function gained bounded readiness polling and a recovery landoStart() retry pass, but had no test coverage for those branches — leaving success/retry/failure paths unverified and prone to silent regression.

Changes

  • Mock dev-environment-lando – added jest.mock for the lando module and imports for isEnvUp, landoStart, landoRebuild, getProxyContainer, landoInfo so each test can control readiness behavior independently.
  • Three new startEnvironment test cases under a readiness polling and retry describe block:
    • Success on first checkisEnvUp returns true immediately; asserts no retry landoStart is issued.
    • Success after retryisEnvUp exhausts all 6 first-pass attempts, then resolves on the second pass; asserts landoStart retry fires exactly once and isEnvUp is called 7 times total.
    • Total failureisEnvUp always returns false; asserts both passes exhaust all 12 attempts and a UserError is thrown.
  • Fake timers – tests that exercise the full polling loop use jest.useFakeTimers() + jest.runAllTimersAsync() to avoid real 2-second sleep delays. The failure-case rejection handler is registered before runAllTimersAsync() to prevent spurious unhandled-rejection failures.
  • Scoped fs.readFileSync mock – intercepts only the instance_data.json path to avoid corrupting lazy module loads (e.g. chalk) during test execution.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 22, 2026 18:32
Co-authored-by: rinatkhaziev <459254+rinatkhaziev@users.noreply.github.com>
Co-authored-by: rinatkhaziev <459254+rinatkhaziev@users.noreply.github.com>
@sonarqubecloud
Copy link

Copilot AI changed the title [WIP] WIP Address feedback on Commander migration pull request Add unit tests for startEnvironment() readiness polling and retry logic Feb 22, 2026
Copilot AI requested a review from rinatkhaziev February 22, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants