test: increase unit test coverage including Speak V2 Flux TTS#514
Open
mgama-deepgram wants to merge 7 commits into
Open
test: increase unit test coverage including Speak V2 Flux TTS#514mgama-deepgram wants to merge 7 commits into
mgama-deepgram wants to merge 7 commits into
Conversation
8 tasks
mgama-deepgram
marked this pull request as ready for review
June 30, 2026 22:58
mgama-deepgram
requested review from
GregHolmes,
deepgram-kiley and
dg-coreylweathers
as code owners
June 30, 2026 22:58
Contributor
|
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.
Proposed changes
Increase unit test coverage + coverage reporting in CI
Summary
Adds a comprehensive hand-written unit test suite across the SDK's hand-maintainable surface (core utilities, transport/websocket layer, custom client, generated REST/WS clients, and Speak V2), wires V8 code coverage into CI with an automatic PR comment, and repairs a lockfile broken by an earlier merge. All new tests are frozen in
.fernignoreso they survive the next Fern regeneration.18 new test files,
1167unit tests passing.What changed
CI (
.github/workflows/ci.yml)pull_requestin addition topush.make test-coverage(unit + wire under V8 coverage).testjobpull-requests: write.Tooling
Makefile— newtest-coveragetarget: runs unit + wire in a single vitest invocation so coverage merges into one cobertura + text report (CI readscoverage/cobertura-coverage.xml); the wire-import fixup is reverted even on failure.vitest.config.mts— normalized projectroot/includepaths and added acoverageblock (v8,src/**/*.ts,./coverage)..fernignore— froze all new hand-written test files (and thetests/unit/coredir) so a regen won't delete them.New test coverage (new files unless noted)
core/polyfills,core/reconnecting-websocket,core/runtime-detection,core/utils,core-branches,misc-branches,fetcher-branches.websocket-native,websocket-sockets(generated Socket classes),generated-ws-clients(generatedconnect()query serialization).custom-client-internals,custom-client-browser,custom-client-fallback.rest-clients,barrels,auth/HeaderAuthProvider,file/multipart.Lockfile repair (
package.json,pnpm-lock.yaml)pnpm-lock.yamlbroken by a bad merge (dependency graph referencedcosmiconfig@9.0.2while only9.0.1was defined →ERR_PNPM_LOCKFILE_MISSING_DEPENDENCYin CI).@vitest/coverage-v8to4.1.9to matchvitest@4.1.9(required bystrict-peer-dependencies).pnpm install --frozen-lockfilenow passes.🎙️ Speak V2 (Flux TTS) — coverage changes
All Speak V2 changes in this PR, grouped for review:
New:
tests/unit/speak-v2-coverage.test.ts(mirrors the Python SDK'stest_speak_v2_coverage.py)Raises coverage of
src/api/resources/speak/resources/v2/**from 58% → 100% statements / 32% → 98% branches:client/Client.tsclient/Socket.tsresources/audio/client/Client.tsCovers the gaps left by the existing split tests:
Client.tsconnect()(absent fromgenerated-ws-clients.test.ts) — query-param serialization (string vstoJsonbranches), absent-param omission,queryParams/headers/options merge, and theaudiolazy getter. Uses an aborted signal so no real socket opens.Socket.ts(absent from thedescribe.eachinwebsocket-sockets.test.ts) — event forwarding,readyState, send guards + open path,connect()/close()teardown, all threewaitForOpen()cases,sendBinary, and theSocket is not connectedguard.audio/client/Client.ts(speak-v2-batch.test.tsonly drove the 2xx path) — the400 → BadRequestError, non-400→ DeepgramError, and transport-failure→ handleNonStatusCodeErrorbranches, plus an all-optional-params success case.The one uncovered branch (
audio/Client.ts:79, the?? Productionenv fallback) is only reachable with no configured environment — it would hit the real production host, so it's intentionally left.Modified:
tests/unit/regen-constraints.test.tsAdded two tests pinning the complete member set of
SpeakV2EncodingandSpeakV2SampleRate. The pre-existing test only asserted one member per enum — a regen dropping/renaming a value (e.g. removing the44100sample rate) would have kept coverage at 100% but slipped through. Both also assert the open-string union still holds. (The otherSpeakV2*types undersrc/api/typesare pure type aliases with no runtime code, so they're already effectively fully covered.).fernignore— frozetests/unit/speak-v2-coverage.test.ts(regen-constraints.test.tswas already frozen).Types of changes
What types of changes does your code introduce to the community JavaScript SDK?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments