What
Add a test file packages/kbot/src/doctor.test.ts with unit tests for the diagnostic checks in doctor.ts.
Why
doctor.ts is a critical user-facing command (the first thing people run when something is wrong), but it has zero test coverage. The individual check functions (checkNodeVersion, checkApiKey, checkGit, etc.) are pure enough to test in isolation, and regressions here would confuse new users.
Suggested approach
- Create
packages/kbot/src/doctor.test.ts.
- Test the exported functions:
runDoctor() and formatDoctorReport().
- Mock external dependencies:
- Mock
child_process.execSync for checkNpmVersion, checkGit, etc.
- Mock
./auth.js (loadConfig, isByokEnabled, getByokProvider) for checkApiKey.
- Mock
fetch for checkProviderReachable and checkLocalRuntimes.
- Mock
./machine.js for hardware checks.
- Test cases to cover:
- All checks pass (happy path)
- Missing API key returns
fail status
- Old Node.js version returns
fail status
- Unreachable provider returns
warn status
formatDoctorReport renders pass/warn/fail correctly
- Overall status is
fail if any check fails, warn if any warns
Follow the patterns in existing test files like auth.test.ts and sessions.test.ts.
Files to look at
packages/kbot/src/doctor.ts — The module to test (all check functions + runDoctor + formatDoctorReport)
packages/kbot/src/auth.test.ts — Example of how tests are structured in this project
packages/kbot/src/sessions.test.ts — Another test file to reference for mocking patterns
What
Add a test file
packages/kbot/src/doctor.test.tswith unit tests for the diagnostic checks indoctor.ts.Why
doctor.tsis a critical user-facing command (the first thing people run when something is wrong), but it has zero test coverage. The individual check functions (checkNodeVersion,checkApiKey,checkGit, etc.) are pure enough to test in isolation, and regressions here would confuse new users.Suggested approach
packages/kbot/src/doctor.test.ts.runDoctor()andformatDoctorReport().child_process.execSyncforcheckNpmVersion,checkGit, etc../auth.js(loadConfig,isByokEnabled,getByokProvider) forcheckApiKey.fetchforcheckProviderReachableandcheckLocalRuntimes../machine.jsfor hardware checks.failstatusfailstatuswarnstatusformatDoctorReportrenders pass/warn/fail correctlyfailif any check fails,warnif any warnsFollow the patterns in existing test files like
auth.test.tsandsessions.test.ts.Files to look at
packages/kbot/src/doctor.ts— The module to test (all check functions +runDoctor+formatDoctorReport)packages/kbot/src/auth.test.ts— Example of how tests are structured in this projectpackages/kbot/src/sessions.test.ts— Another test file to reference for mocking patterns