Skip to content

test(snapshot): 28 tests time out waiting on interactive prompt #3

@eduardovrocha

Description

@eduardovrocha

28 of 31 tests in packages/cli/tests/snapshot.test.ts time out at 5000ms because the CLI presents Publish verified profile? [y/N] and the test harness has no mechanism to suppress or auto-respond.

Root cause

packages/cli/src/commands/snapshot.ts:319 has the only guard:

if (!process.stdin.isTTY) return false;

The prompt is suppressed only when stdin is not a TTY. CI runners (GitHub Actions) have non-TTY stdin → isTTY is undefined → prompt is skipped. A developer's local terminal has TTY stdin → isTTY is true → prompt appears → test times out.

This is an implicit, undocumented dependency on CI environment behavior. Local execution should not require running in a non-TTY mode (bun test < /dev/null) to validate the snapshot command.

Reproduction

git checkout main
bun test packages/cli/tests/snapshot.test.ts
# 3 pass / 28 fail (all timeout at prompt)

Recommended fix

Add an explicit env-var guard before the TTY check, defaulting to current behavior unless opted in/out:

if (process.env.BEHELD_YES === '1') return true;
if (process.env.BEHELD_NO_PROMPT === '1') return false;
if (!process.stdin.isTTY) return false;

Then in a new packages/cli/tests/setup.ts (registered via bunfig.toml [test] section):

process.env.BEHELD_NO_PROMPT = '1';

Per-test override, where the prompt path is exercised explicitly:

process.env.BEHELD_YES = '1';

Acceptance criteria

  • All 31 snapshot tests pass with bun test packages/cli/tests/snapshot.test.ts on a developer's local TTY terminal
  • The env-var contract is documented in the test file header and in CONTRIBUTING (or equivalent)
  • CI behavior remains unchanged

Estimated effort

1-2 hours including writing 1-2 tests that explicitly verify the prompt path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions