Repository navigation
test(registry): type-check and run documented examples (PLT-845) - #360
Conversation
Collect the TypeScript block in the README and every JSDoc @example, type-check them against the package source, and run them against the package exports, so an example that stops compiling or stops finding data fails the suite. Co-authored-by: Cursor <cursoragent@cursor.com>
PR SummaryLow Risk Reviewed by Cursor Bugbot for commit da96c5a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
This PR adds only a test, and it does what the PLT-845 follow-up asked for: it type-checks the registry README example and every JSDoc @example under strict, then runs each one and fails when a value it declares or logs is undefined. I found no blocking issues; the notes below are about cases the runtime check can miss. I couldn't run the suite here because executing it needed approval, so this review is from reading the code.
Findings: 0 blocking | 7 non-blocking | 4 posted inline
Blockers
- None at the file/PR level.
Non-blocking
- The Codex and Cursor review files were both empty, so this review has no second opinions.
- No changeset is needed: the PR only adds a test under
src/__tests__, whichtsconfig.jsonexcludes and the package'sfiles: ["dist"]does not publish. This matches section 3 of the guidelines. - Consider adding a few small unit tests for the extraction helpers (
codeBlocks,jsdocExamples,declaredNames) using fixture strings. Right now a regex change that silently matches zero blocks would leave the suite passing without checking anything. A cheap guard is to assertexamples.lengthis above a minimum. - 4 suggestion(s)/nit(s) flagged inline on specific lines.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #360 +/- ##
=======================================
Coverage 96.53% 96.53%
=======================================
Files 81 81
Lines 5563 5563
=======================================
Hits 5370 5370
Misses 193 193
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Accept fence info strings and CRLF line endings, report an @example without a code block as a failing test instead of a load error, and check destructured bindings. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
This PR adds one test file and changes no published code. It type-checks the registry README example and every JSDoc @example in src/, then runs them, which stops the PLT-845 doc bugs coming back. I found nothing blocking, only small robustness nits.
Findings: 0 blocking | 6 non-blocking | 3 posted inline
Blockers
- None at the file/PR level.
Non-blocking
- The Codex (
codex-review.md) and Cursor (cursor-review.md) review files were both empty, so this review has no second opinion. - No changeset is needed. Only a spec file under
src/__tests__/changes, andtsconfig.jsonexcludes that folder from the build. typescriptis already a registry devDependency, so the newimport ts from 'typescript'adds no dependency.- 3 suggestion(s)/nit(s) flagged inline on specific lines.
Check every @example tag for its own code block rather than every comment, and report the tag's line. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
This PR adds only a test, examples.spec.ts, which type-checks the registry's README and JSDoc @example blocks and runs them, so the PLT-845 doc bugs fail CI if they come back. It looks correct and is test-only; the notes below are minor robustness gaps in how examples are collected and checked.
Findings: 0 blocking | 6 non-blocking | 3 posted inline
Blockers
- None at the file/PR level.
Non-blocking
- The OpenAI Codex and Cursor second-opinion reviews (
codex-review.md,cursor-review.md) were empty, so this review is the only pass. - The test relies on the global
describe/it/jest.spyOnthatbun testprovides instead of importing them frombun:test. That works underbun test --isolate src, but addingimport { describe, expect, it, jest } from 'bun:test'would make the dependency explicit and keep editor and type tooling happy. - No changeset is needed: the PR is test-only and the published package's behaviour, types and dependencies are unchanged (
typescriptis already a devDependency). - 3 suggestion(s)/nit(s) flagged inline on specific lines.
Summary
src/__tests__/examples.spec.ts, which collects the TypeScript blocks in the registry README and every JSDoc@exampleundersrc/strictagainst the package source, with@sei-js/registrymapped tosrc/index.ts, and report errors at the README or source line they come fromundefined, so a lookup that stops matching the pinned asset data fails too@exampletag has no TypeScript code block, or when the README or the JSDoc yields no examples, instead of skipping themRelated issue
PLT-845. The three doc bugs it describes were fixed in #327, #329 and #342. This adds the example test from its scope so they can't come back.
Test plan
bun run checkbun run buildbun run testTOKEN_LIST.findin the README,NETWORKS.findin the JSDoc, no./walletsexport) and confirmed the suite fails on each:undefined, destructured a missing wallet, and exported anundefinedvalue; each fails the runtime check@exampleto the wallets comment (fails the collection test assrc/wallets/index.ts:45) and relabelled the README fencets viem(still collected)lcov.infolists onlypackages/registry/srcfiles, still at 100%Changeset not required because this only adds a test.
Made with Cursor