Skip to content

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

Open
NikkiAung wants to merge 1 commit 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 1 commit into
solana-foundation:mainfrom
NikkiAung:feat/node-test-runner-all

Conversation

@NikkiAung

@NikkiAung NikkiAung commented Jul 21, 2026

Copy link
Copy Markdown

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

…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 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 migrates the remaining non-Anchor basics tests to Node’s built-in test runner. The main changes are:

  • Replaces ts-mocha test scripts with tsx --test.
  • Replaces Mocha and Chai dependencies with tsx and Node types.
  • Converts six test files to node:test and node:assert.
  • Regenerates each affected package lockfile.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The explicit Node test imports preserve the existing suite and hook behavior.
  • The converted assertions preserve the tested value comparisons.

Important Files Changed

Filename Overview
basics/cross-program-invocation/native/tests/test.ts Adds explicit Node test imports and renames it registrations to test.
basics/cross-program-invocation/pinocchio/tests/test.ts Moves suite registration and assertions from Mocha and Chai to Node APIs.
basics/favorites/native/tests/test.ts Moves hooks and tests to node:test and converts Chai comparisons to strict Node assertions.
basics/favorites/pinocchio/tests/test.ts Replaces the stub suite’s Mocha import with node:test.
basics/hello-solana/asm/tests/index.test.ts Converts the suite, setup hook, test, and assertions to Node APIs.
basics/hello-solana/pinocchio/tests/index.test.ts Converts the suite, setup hook, test, and assertions to Node APIs.

Reviews (1): Last reviewed commit: "feat(basics): migrate remaining 29 progr..." | Re-trigger Greptile

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