Skip to content

refactor(test): standardize log capture on useCaptureLog#287

Draft
wyattjoh wants to merge 1 commit into
wyattjoh/nextjs-pinned-rangefrom
wyattjoh/use-capture-log
Draft

refactor(test): standardize log capture on useCaptureLog#287
wyattjoh wants to merge 1 commit into
wyattjoh/nextjs-pinned-rangefrom
wyattjoh/use-capture-log

Conversation

@wyattjoh
Copy link
Copy Markdown
Contributor

@wyattjoh wyattjoh commented May 13, 2026

Summary

Standardize unit-test log capture on a single helper, and stabilize the integration harness.

Unit-test log capture is rebuilt on top of a useCaptureLog() lifecycle helper that installs a fresh buffer per test via beforeEach/afterEach, replacing the prior AsyncLocalStorage-backed captureLog().run(...) wrapper. With the slot installed automatically, test bodies no longer wrap their emitting calls. As part of this, log.ui() stops appending its own trailing newline so spinner cursor-control writes survive, the cli-program writeErr newline-stripping workaround that compensated for the old behavior is removed, and a latent double-newline bug in the spinner output is fixed by moving the trailing \n onto each emitting call site.

The integration harness's config load moves out of a top-level await so each test gets a fresh instance, and a new harness test covers the new shape.

Test plan

  • bun run format:check
  • bun run lint
  • bun run typecheck
  • bun run test

@wyattjoh
Copy link
Copy Markdown
Contributor Author

Stack: wyattjoh/nextjs-pinned-range

Part of a stacked PR chain. Do not merge manually.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

⚠️ No Changeset found

Latest commit: 8cc424a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@wyattjoh wyattjoh changed the title refactor(test): standardize log capture on useCaptureLog and stabilize integration harness refactor(test): standardize log capture on useCaptureLog May 13, 2026
…e integration harness

Replace ad-hoc log spy patterns across every command and lib test with the
useCaptureLog helper. Refactor log.ts and spinner.ts so the helper can hook
in cleanly, drop unused test-helper imports as a side effect.

Add a harness test covering the lazy config-module loader so each test gets
a fresh instance.
@wyattjoh wyattjoh force-pushed the wyattjoh/use-capture-log branch from 88c14ab to 8cc424a Compare May 13, 2026 20:03
@wyattjoh wyattjoh force-pushed the wyattjoh/nextjs-pinned-range branch from 2ca4be0 to 5e0198f Compare May 13, 2026 20:03
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