Skip to content

test: adopt @doist/cli-core/testing shared helpers#78

Merged
scottlovegrove merged 2 commits into
mainfrom
test/adopt-cli-core-testing-helpers
May 24, 2026
Merged

test: adopt @doist/cli-core/testing shared helpers#78
scottlovegrove merged 2 commits into
mainfrom
test/adopt-cli-core-testing-helpers

Conversation

@scottlovegrove
Copy link
Copy Markdown
Contributor

Summary

  • Replace bespoke inline test scaffolding with the published @doist/cli-core/testing helpers, mirroring todoist-cli#361 (per cli-core#49).
  • createTestProgram(register) replaces inline new Command(); exitOverride(); registerX(program) harness blocks across commands, changelog-integration, empty-output, and auth-command tests.
  • captureConsole(method?) replaces inline vi.spyOn(console, …) recorders and the local captureLogs/captureStreams helpers; assertions now read the spy's .mock.calls via a small lines() accessor.
  • Bump @doist/cli-core 0.23.0 → 0.24.0, which ships these helpers. No source/runtime files changed.

Notes / deviations

  • No captureStream usage — outline-cli has no process.stdout/stderr.write spies (todoist adopted it via mockProcessStdout).
  • Skipped the buildTokenStore/account fixtures, same as todoist-cli — outline's auth tests are module-level vi.mock interaction mocks, the wrong shape for cli-core's stateful store fake.
  • captureConsole takes a single method string (captureConsole('error')), per the published 0.24 .d.ts.

Test plan

  • npm run type-check
  • npm run lint:check — 0 warnings, 0 errors
  • npm run format:check
  • npm test — 188 tests pass (21 files)

🤖 Generated with Claude Code

Replace bespoke inline test scaffolding with the published
@doist/cli-core/testing helpers, mirroring todoist-cli#361 (cli-core#49):

- createTestProgram(register) replaces inline `new Command(); exitOverride();
  registerX(program)` harness blocks.
- captureConsole(method?) replaces inline `vi.spyOn(console, …)` recorders
  and the local captureLogs/captureStreams helpers; assertions read the
  spy's .mock.calls via a small lines() accessor.

Bump @doist/cli-core 0.23.0 -> 0.24.0, which ships these helpers. No
source/runtime files changed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does a great job standardizing the test suite by replacing custom scaffolding with the shared @doist/cli-core/testing helpers like createTestProgram and captureConsole. These updates make the tests much cleaner and align the repository's patterns more closely with the rest of the CLI ecosystem. There is just a minor opportunity to further reduce repetition by lifting the duplicated lines() helper to the top level of the test file so it can be shared across all describe blocks and spy assertions.

Share FeedbackReview Logs

Comment thread src/commands/commands.test.ts Outdated
Address review: dedupe the per-describe lines() helper into a single
top-level function (matching auth-command.test.ts) and reuse it for the
errorSpy assertions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove merged commit b42ab37 into main May 24, 2026
5 checks passed
@scottlovegrove scottlovegrove deleted the test/adopt-cli-core-testing-helpers branch May 24, 2026 11:49
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants