tests: add Vitest coverage + cross-platform throwaway-Neo4j wrappers#27
Merged
Conversation
stevepridemore
added a commit
that referenced
this pull request
May 10, 2026
…rs (#27) - New devDep @vitest/coverage-v8; coverage block in vitest.config.ts using v8 provider, text + html reporters, sensible exclude list (dist, scripts, prompts, *.test.ts, *.config.ts, coverage). No thresholds — measure first, decide later. - Three new npm scripts: test:coverage — vitest run --coverage (assumes NEO4J_* env set; CI uses this) test:local — wrapper-driven full suite, no coverage test:coverage:local — wrapper-driven full suite with coverage - scripts/test-with-neo4j.sh and .ps1 wrappers spin up a throwaway neo4j:5.20-community on :7689 with NEO4J_AUTH=neo4j/test1234, wait for readiness via cypher-shell polling, run vitest with forwarded args, guarantee teardown via trap/finally even on Ctrl-C or test failure. Idempotent — removes any leftover container before starting. - CI test job now runs `npm run test:coverage` against its existing service container, so coverage numbers are real (not lowered by Neo4j-test failures the way local-without-throwaway would be). - docs/TESTING.md: new Coverage section explains the three commands, reporters (text + html), local Docker requirement, PowerShell fallback when bash isn't on PATH, and CI behaviour. Test-suite table refreshed to include oauth-events and read-body tests added in PRs #17 and #24, with a non-numeric phrasing for the suite size so the doc doesn't drift again. - vitest.config.ts excludes .claude/** at the test level — caught during verification when the agent's worktree under .claude/ caused vitest to discover duplicate test files. Project-level fix unrelated to coverage. Baseline coverage on this run (133 tests, 4 files): 65% statements, 67% lines project-wide. Best covered: oauth-events.ts (100%), oauth.ts (82%), read-body.ts (80%). Largest gap: neo4j-client.ts (57%) — fault-injection paths not unit-tested. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 Vitest test coverage measurement with cross-platform wrapper scripts that handle the throwaway-Neo4j container, so a developer can run
npm run test:coverage:localand get accurate numbers locally that match what CI computes.Changes
@vitest/coverage-v8(faster than istanbul, no source instrumentation)vitest.config.ts: coverage block — v8 provider, text + html reporters, sensible exclude list. No thresholds (measure first, decide later).test:coverage— assumesNEO4J_*env set; CI uses thistest:local— wrapper-driven full suite, no coveragetest:coverage:local— wrapper-driven full suite with coverage (the primary local command)scripts/test-with-neo4j.{sh,ps1}: spin upneo4j:5.20-communityon:7689withNEO4J_AUTH=neo4j/test1234, wait for readiness viacypher-shellpolling (60 s cap), run vitest with forwarded args, guarantee teardown viatrap/finally. Idempotent (removes leftover container at start).Testjob now runsnpm run test:coverageagainst its existing service container — coverage numbers are real, not artificially lowered by Neo4j-test failures.docs/TESTING.md: new Coverage section. Test-suite table refreshed to includeoauth-events.test.tsandread-body.test.ts(added in OAuth event logging (closes R-1, I-3) #17 and Cap readBody to 64 KB / 4 MB by route (closes D-3) #24); suite-size phrasing made non-numeric so the doc doesn't drift again.vitest.config.tsalso excludes.claude/**from test discovery — caught during verification when an agent worktree under.claude/caused duplicate test discovery. Project-level fix unrelated to coverage.Baseline coverage
Captured on this branch (133 tests across 4 files):
oauth-events.tsoauth.tsread-body.tsembeddings.tsconfig.tsneo4j-client.tsBest covered:
oauth-events.ts,oauth.ts,read-body.ts— recent test discipline pays off. Largest gap:neo4j-client.ts(57%) — fault-injection paths (Cypher errors, transaction rollbacks, connection failures) not unit-tested.Test plan
npm run buildcleannpm run test:coverage:localruns end-to-end on Windows (Git Bash) — 133 passing, container torn down on exitnpm run test:coverageagainst service container and prints coverage summary in theTestjob logOut of scope
🤖 Generated with Claude Code