test: vitest scaffold + pure helpers (28 tests) - #12
Open
chronostrophe wants to merge 1 commit into
Open
Conversation
- src/util/format.ts: redactUrls, isDebugEnabled, formatCaughtError (extracted from the inline catch handler so the DEBUG+redaction logic is unit-testable) - src/util/steps.ts: extractSteps with position-ordered regex (preserves body-position ordering; dedupes via Set) - src/index.ts: route the MCP catch handler through formatCaughtError + isDebugEnabled; skip the redundant 'Error: <msg>' first line of V8 stacks so the message isn't repeated in the output - tests/util/format.test.ts (19 tests): URL redaction across http/https/ws, parens handling, multi-URL, non-URL preservation, DEBUG truthy/falsy literals, formatCaughtError with debug on/off and stack-line cap, non-Error throws - tests/util/steps.test.ts (9 tests): empty/no-match, short-UI filter, trailing-context kept, insertion order, dedup, 100-char truncation, all 7 verbs, real-world Comet body with mixed signal+noise - package.json: vitest devDep + scripts (test, test:watch) - vitest.config.ts: node env, tests/**/*.test.ts Verified: npx tsc --noEmit clean; npm test → 28/28 passing in 1.7s. L2 re-investigated with grep references: state.currentUrl IS assigned in connect() (line 810) and navigate() (line 834); the L2 alarm was a false positive from initial analysis.
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a vitest test scaffold and extracts pure helpers from
src/index.tsso the trickiest logic is unit-testable without a live browser.src/util/format.ts:formatCaughtError(redaction-safe error formatting, DEBUG-gated) +isDebugEnabled.src/util/steps.ts: agent step-list pure helpers.tests/util/*.test.ts: 28 tests covering redaction rules, error formatting edge cases, and step helpers.vitest.config.ts+npm test/npm run typecheckscripts.cometClient.disconnect()is idempotent) — without it, a killed process can leave Comet with a dangling debugger attach that stalls the nextcomet_connect.Test plan
npm test— 28/28 passnpx tsc --noEmit— cleanupstream/main(6f10c86) — no other commits requiredNo behavior change to the happy path; error text now goes through the redaction helper.