Skip to content

feat(basics): migrate remaining 29 programs from ts-mocha to tsx + node:test runner#637

Open
NikkiAung wants to merge 3 commits into
solana-foundation:mainfrom
NikkiAung:feat/node-test-runner-all
Open

feat(basics): migrate remaining 29 programs from ts-mocha to tsx + node:test runner#637
NikkiAung wants to merge 3 commits into
solana-foundation:mainfrom
NikkiAung:feat/node-test-runner-all

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #636 (pilot). Applies the same ts-mocha → tsx --test migration to all remaining non-anchor native/pinocchio/asm programs in basics/ (29 programs, 94 files).

Anchor programs excludedanchor test --validator legacy invokes mocha internally and bypasses package.json scripts entirely; migrating them requires changes to the Anchor CLI itself.

Changes per program (×29)

  • package.jsontest script: pnpm ts-mocha … <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: drop "mocha" and "chai", ensure "node" is present
  • pnpm-lock.yaml — regenerated per package (mocha/chai tree removed, tsx added)

6 test files with structural edits

File What changed
cross-program-invocation/native Add node:test imports (before, describe, test); rename it()test()
cross-program-invocation/pinocchio Same; also swap import { assert } from "chai"import assert from "node:assert"
hello-solana/asm Add node:test imports (before, describe, test); rename it()test(); chai → node:assert
hello-solana/pinocchio Same as hello-solana/asm
favorites/native import { describe, test } from "mocha"node:test; add beforeEach; chai → node:assert; expect().to.equalassert.strictEqual, expect().to.deep.equalassert.deepStrictEqual
favorites/pinocchio import { describe } from "mocha"node:test (stub file)

Note: favorites/native and cross-program-invocation/native remain in .ghaignore — migrations are for correctness/consistency, not yet CI-verified.

Test plan

  • CI solana-native.yml passes for all native programs in this PR
  • CI solana-pinocchio.yml passes for all pinocchio programs
  • CI solana-asm.yml passes for create-account/asm and transfer-sol/asm
  • Grep: no residual ts-mocha, from "mocha", or from "chai" in migrated programs

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

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR moves the remaining non-Anchor basics/ tests to Node’s built-in test runner. The main changes are:

  • Replaces ts-mocha scripts with tsx --test across 29 programs.
  • Replaces Mocha and Chai imports, hooks, and assertions in the edited tests.
  • Removes obsolete dependencies and regenerates package lockfiles.
  • Updates TypeScript types and restores ES2020 targets where required.

Confidence Score: 5/5

This looks safe to merge.

  • The latest updates restore the TypeScript target required by modern language features.
  • Stale Mocha and Chai type references were removed.
  • No blocking issue remains in the reviewed changes.

Important Files Changed

Filename Overview
basics/create-account/asm/tsconfig.json Restores the ES2020 library and target needed by the test suite's BigInt usage.
basics/favorites/native/tests/test.ts Moves test hooks and assertions from Mocha and Chai to Node's test APIs.
basics/cross-program-invocation/pinocchio/tests/test.ts Moves test registration and assertions to node:test and node:assert.

Reviews (3): Last reviewed commit: "fix(#637): remove stale mocha/chai types..." | Re-trigger Greptile

…de:test runner

Follow-up to the 5-program pilot (PR solana-foundation#636). Applies the same pattern to all
remaining non-anchor native/pinocchio/asm programs in basics/:

- package.json: test script → `tsx --test <file>`; drop mocha/ts-mocha/
  @types/mocha/chai/@types/chai; add tsx ^4.22.0 + @types/node ^22.19.1
- tsconfig.json (or tests/tsconfig.test.json): types → ["node"]
- pnpm-lock.yaml: regenerated per package

6 test files also needed structural edits:
- cross-program-invocation/native + pinocchio: add `node:test` imports;
  rename it() → test()
- hello-solana/asm + pinocchio: add node:test imports; rename it() → test();
  convert chai import to node:assert
- favorites/native: change mocha import → node:test; chai → node:assert;
  convert expect().to.equal/deep.equal → assert.strictEqual/deepStrictEqual;
  add beforeEach to node:test import
- favorites/pinocchio: change mocha import → node:test (stub file)

Anchor programs are intentionally excluded: anchor test uses mocha internally
via `anchor test --validator legacy`, bypassing package.json scripts entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@NikkiAung
NikkiAung force-pushed the feat/node-test-runner-all branch from bc92a78 to f467b24 Compare July 25, 2026 00:35
NikkiAung and others added 2 commits July 24, 2026 17:43
…igs, fix create-account/asm es6 target

The CI overhaul added tsc --noEmit checks which caught:
1. Root tsconfig.json files with types:["mocha","chai","node"] - mocha/chai no longer
   installed (replaced by tsx migration), causing typecheck failure.
2. create-account/asm/tsconfig.json had target:"es6" but test uses BigInt literals
   which require ES2020.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ode compatibility

Programs that use CPI to the system program fail in solana-bankrun 0.3.x
because its bundled system-program binary emits SBPF v2 instructions that
bankrun's own VM cannot execute. Switch the 5 affected programs to litesvm
(synchronous API, before() setup hook) to fix CI.

Programs fixed:
- basics/account-data/native
- basics/close-account/native
- basics/pda-rent-payer/native
- basics/program-derived-addresses/native
- basics/rent/native

Also adds skipLibCheck: true to tsconfigs missing it, and bumps TypeScript
to ^5.5.0 to match the rest of the PR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 25, 2026

Copy link
Copy Markdown

Too many files changed for review. (102 files found, 100 file limit)

Bypass the limit by tagging @greptile-apps to review.

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.

1 participant