Skip to content

test(registry): type-check and run documented examples (PLT-845) - #360

Merged
alexander-sei merged 3 commits into
mainfrom
alexanderh/plt-845-sei-jsregistry-wrong-api-examples-in
Nov 12, 2026
Merged

alexander-sei merged 3 commits into
mainfrom
alexanderh/plt-845-sei-jsregistry-wrong-api-examples-in

Conversation

@alexander-sei

@alexander-sei alexander-sei commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • add src/__tests__/examples.spec.ts, which collects the TypeScript blocks in the registry README and every JSDoc @example under src/
  • type-check each example under strict against the package source, with @sei-js/registry mapped to src/index.ts, and report errors at the README or source line they come from
  • run each example against the package exports and fail when a value it declares (destructured bindings included) or logs is undefined, so a lookup that stops matching the pinned asset data fails too
  • fail a named test when an @example tag has no TypeScript code block, or when the README or the JSDoc yields no examples, instead of skipping them

Related 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 check
  • bun run build
  • bun run test
  • put the PLT-845 bugs back (TOKEN_LIST.find in the README, NETWORKS.find in the JSDoc, no ./wallets export) and confirmed the suite fails on each:
    README.md:11: Module '"@sei-js/registry"' has no exported member 'WALLETS'.
    README.md:13: Property 'find' does not exist on type 'SeiTokenList'.
    src/networks/index.ts:67: Property 'find' does not exist on type 'NetworksConfig'.
    src/wallets/index.ts:41: Module '"@sei-js/registry"' has no exported member 'WALLETS'.
    
  • changed the token lookup to a symbol that isn't in the list, logged a value that is undefined, destructured a missing wallet, and exported an undefined value; each fails the runtime check
  • added a second, unfenced @example to the wallets comment (fails the collection test as src/wallets/index.ts:45) and relabelled the README fence ts viem (still collected)
  • ran the CI coverage command for registry: lcov.info lists only packages/registry/src files, still at 100%

Changeset not required because this only adds a test.

Made with Cursor

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>
@cursor

cursor Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only change in the registry package; no production code or runtime behavior changes.

Reviewed by Cursor Bugbot for commit da96c5a. Bugbot is set up for automated code reviews on this repo. Configure here.

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__, which tsconfig.json excludes and the package's files: ["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 assert examples.length is above a minimum.
  • 4 suggestion(s)/nit(s) flagged inline on specific lines.

@codecov-commenter

codecov-commenter commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.53%. Comparing base (9fd7061) to head (da96c5a).

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           
Flag Coverage Δ
mcp-server 95.15% <ø> (ø)
precompiles 99.85% <ø> (ø)
registry 100.00% <ø> (ø)
sei-global-wallet 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and tsconfig.json excludes that folder from the build.
  • typescript is already a registry devDependency, so the new import 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>

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.spyOn that bun test provides instead of importing them from bun:test. That works under bun test --isolate src, but adding import { 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 (typescript is already a devDependency).
  • 3 suggestion(s)/nit(s) flagged inline on specific lines.

@alexander-sei
alexander-sei merged commit 2f746a0 into main Nov 12, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants