Skip to content

feat(inquirerer-test): add runCli subprocess helper + Testing docs#79

Merged
pyramation merged 1 commit intomainfrom
feat/inquirerer-test-subprocess
Apr 26, 2026
Merged

feat(inquirerer-test): add runCli subprocess helper + Testing docs#79
pyramation merged 1 commit intomainfrom
feat/inquirerer-test-subprocess

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Adds a runCli subprocess helper to @inquirerer/test and surfaces the package from inquirerer's own README so it's actually discoverable.

What's new in @inquirerer/test (sibling to the existing in-process createTestEnvironment/createTestFixture):

  • runCli(bin, args, options?) — spawn a CLI binary, capture stdout/stderr, enforce a timeout, and assert on exit code. Defaults match common Jest expectations: rejects on non-zero exit with captured streams attached to RunCliError; pass reject: false to inspect failures without try/catch.
  • parseArgString(args) — split a shell-like string into an argv array (whitespace + quote-aware, no shell expansion).
  • RunCliError — typed error with stdout / stderr / exitCode / signal / timedOut / command fields.

Why now

Hand-rolled subprocess harnesses keep showing up (spawn + arg-string parser + timeout + stdout/stderr capture) any time someone wants a real CLI E2E test. The in-process createTestEnvironment is great for unit-testing prompts but doesn't help when the test needs the actual built executable. Now both shapes live in one package.

Inquirerer README discoverability

The companion test package was effectively invisible from inquirerer's docs — no Testing section, no link. Added a small Testing section that shows both the in-process and subprocess flows and links to the full @inquirerer/test README.

Files

  • packages/inquirerer-test/src/subprocess.ts — new helper
  • packages/inquirerer-test/src/index.ts — re-exports runCli, parseArgString, RunCliError, RunCliOptions, RunCliResult
  • packages/inquirerer-test/__tests__/subprocess.test.ts — 14 tests covering parseArgString (5) and runCli (9: stdout/stderr capture, default reject behaviour, error attachment, reject: false, stdin piping, custom cwd/env, timeout, spawn error)
  • packages/inquirerer-test/README.md — new "Subprocess Testing (CLI E2E)" section + API table
  • packages/inquirerer/README.md — new "Testing" section pointing at @inquirerer/test

Review & Testing Checklist for Human

  • Skim subprocess.ts API surface — happy with runCli(bin, args, options) signature, default 30s timeout, default reject: true, RunCliError shape?
  • Confirm the docstring example for env (replaces parent env when set) matches the policy you want — the alternative would be "merge with parent" but I matched Node's child_process.spawn semantics for least surprise.
  • Confirm package version bump policy — this is a feature add so should land as a minor (1.4.0); leaving the version at 1.3.5 for whoever's running lerna version.

Notes

  • 14/14 tests pass locally (pnpm --filter @inquirerer/test test).
  • Build passes (pnpm --filter @inquirerer/test build) — both CJS and ESM.
  • Follow-up downstream PRs (separate, not in this PR):
    • constructive-io/constructive: drop the local test-utils re-export and import from @inquirerer/test directly.
    • constructive-io/agentic-db: replace the hand-rolled runCli in cli-e2e-tests with this one.

Link to Devin session: https://app.devin.ai/sessions/81001448b7c54b8099437f706d44a30d
Requested by: @pyramation

… inquirerer

Adds a runCli/parseArgString helper to @inquirerer/test for end-to-end
CLI subprocess tests, alongside the existing in-process Inquirerer
harness. Defaults match common Jest expectations: rejects on non-zero
exit (with captured stdout/stderr/exitCode attached to RunCliError),
inherits the parent env unless overridden, 30s default timeout,
configurable kill signal, and an opt-out (`reject: false`) for
inspecting failure cases.

Also adds a Testing section to inquirerer's main README pointing at
@inquirerer/test so the helper is discoverable from the consumer side.
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

1 participant