Skip to content

feat(basics): migrate 5 pilot programs from ts-mocha to tsx + node:test runner#636

Open
NikkiAung wants to merge 1 commit into
solana-foundation:mainfrom
NikkiAung:feat/node-test-runner
Open

feat(basics): migrate 5 pilot programs from ts-mocha to tsx + node:test runner#636
NikkiAung wants to merge 1 commit into
solana-foundation:mainfrom
NikkiAung:feat/node-test-runner

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 21, 2026

Copy link
Copy Markdown

Summary

All basics/ native/pinocchio/asm test files already import describe/test from node:test, yet they're launched through ts-mocha which contributes nothing — node:test self-registers and auto-runs at process exit. This PR removes the dead mocha launcher and standardises the 5 pilot programs on:

  • Runner: tsx --test <file> (matches pattern already in use at games/world-cup/pinocchio)
  • Assertions: node:assert (drop chai)
  • Types: @types/node only (drop @types/mocha, @types/chai)

Pilot programs (5) — chosen to cover all variants

Program CI workflow Runtime Assertion change
basics/hello-solana/native native solana-bankrun chainode:assert
basics/counter/native native solana-bankrun chainode:assert
basics/account-data/pinocchio pinocchio litesvm none (bare throw)
basics/checking-accounts/asm asm solana-bankrun none (already node:assert)
basics/create-account/native native solana-bankrun none (no assertions)

Changes per program

  • package.jsontest script: pnpm ts-mocha -p ... -t 1000000 <file>tsx --test <file>; drop mocha/ts-mocha/@types/mocha/chai/@types/chai; add tsx ^4.22.0 + @types/node ^22.19.1
  • tsconfig.jsontypes: ["mocha","chai"(,"node")]["node"]
  • hello-solana/native + counter/native test files — import { assert } from "chai"import assert from "node:assert" (identical truthy semantics; no call-site edits)
  • pnpm-lock.yaml — regenerated per package (mocha/chai tree removed, tsx added)

No CI workflow changes needed — tests are invoked via the pnpm test script that build-and-test already chains into.

Test plan

  • CI solana-native.yml passes for hello-solana/native, counter/native, create-account/native
  • CI solana-pinocchio.yml passes for account-data/pinocchio
  • CI solana-asm.yml passes for checking-accounts/asm
  • Grep: no residual ts-mocha, "mocha", or from "chai" in the 5 programs
  • Follow-up PR to migrate remaining ~29 basics programs once this pilot is green

@NikkiAung
NikkiAung requested a review from dev-jodee as a code owner July 21, 2026 05:30
@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR migrates five pilot programs from ts-mocha to the Node test runner. The main changes are:

  • Runs TypeScript tests with tsx --test.
  • Replaces Chai assertions with node:assert where needed.
  • Removes Mocha and Chai dependencies and types.
  • Regenerates each pilot program's pnpm lockfile.

Confidence Score: 5/5

This looks safe to merge.

  • The regenerated lockfiles match the five changed manifests.
  • The CI pnpm version supports the committed lockfile format.
  • No blocking issues remain in the updated code.

Important Files Changed

Filename Overview
basics/account-data/pinocchio/package.json Moves the test script and dependencies from ts-mocha to tsx and Node types.
basics/checking-accounts/asm/package.json Moves the ASM test script and dependencies to tsx and the Node test runner.
basics/counter/native/package.json Moves the counter test script and dependencies to tsx and Node types.
basics/create-account/native/package.json Moves the native test script and dependencies to tsx and the Node test runner.
basics/hello-solana/native/package.json Moves the test script and dependencies from ts-mocha to tsx and Node types.
basics/counter/native/tests/counter.test.ts Replaces the Chai truthiness assertion import with node:assert.
basics/hello-solana/native/tests/index.test.ts Replaces the Chai truthiness assertion import with node:assert.

Reviews (2): Last reviewed commit: "feat(basics): migrate 5 programs from ts..." | Re-trigger Greptile

Comment thread basics/account-data/native/package.json Outdated
…ner (pilot)

Replaces ts-mocha with `tsx --test` as the test runner for the first 5
pilot programs, removing the dead mocha layer that was present alongside
node:test API imports.

Changes per program:
- package.json: swap `test` script to `tsx --test <file>`, drop
  mocha/ts-mocha/@types/mocha/chai/@types/chai devDeps, add tsx + @types/node
- tsconfig: update `types` from ["mocha","chai"(,"node")] → ["node"]
- hello-solana/native + counter/native: convert `import { assert } from "chai"`
  → `import assert from "node:assert"` (identical truthy semantics, no call-site edits)
- pnpm-lock.yaml: regenerated per package to reflect new deps

Pilots cover every variant: both tsconfig conventions (root / tests/), both
runtimes (solana-bankrun / litesvm), all 3 CI workflows (native, pinocchio, asm),
and all assertion styles (chai convert, bare throw, node:assert already, none).
No CI workflow changes needed — tests are invoked via the `pnpm test` script
that `build-and-test` already chains into.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dev-jodee

Copy link
Copy Markdown
Collaborator

the regenerated lockfiles dropped the libc fields on the litesvm Linux packages (they're present on main). Not breaking CI since the runners are glibc, but it can pull the wrong binary on musl/Alpine. Looks like it was regenerated with a pnpm other than the pinned 10.33.0. Can you redo them with:

corepack use pnpm@10.33.0
pnpm install --lockfile-only

@dev-jodee dev-jodee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the comment above ^

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