Skip to content

CLI Reference - Testship Command Line Interface Documentation

TestShip provides a command-line interface (CLI) for starting and managing the interactive testing server for your Anchor programs.

Run TestShip directly without installation:

Terminal window
npx @blockchain-hq/testship@latest start

Benefits of npx:

  • ✅ Always uses the latest version
  • ✅ No global installation required
  • ✅ No version management needed
  • ✅ Perfect for CI/CD and temporary usage

Install TestShip globally for repeated use:

Terminal window
npm install -g @blockchain-hq/testship
# or
yarn global add @blockchain-hq/testship
# or
pnpm add -g @blockchain-hq/testship

📦 Package: @blockchain-hq/testship on npm

Starts the TestShip development server with an interactive UI for testing your Anchor program.

Usage:

Terminal window
testship start [options]

Options:

OptionAliasDescriptionDefault
--port <port>-pPort number to run the dev server on3000

Examples:

Terminal window
# Using npx (recommended)
npx @blockchain-hq/testship@latest start
# Start on default port (3000) - if installed globally
testship start
# Start on custom port
npx @blockchain-hq/testship@latest start --port 8080
testship start -p 8080 # if installed globally

Display the current version of TestShip.

Terminal window
testship --version

Display help information for TestShip commands.

Terminal window
testship --help

When you run testship start, the CLI performs the following steps:

  1. Project Detection: Scans the current directory for Anchor.toml to verify it’s an Anchor project
  2. IDL Discovery: Looks for IDL files in target/idl/ directory
  3. Program Selection: If multiple programs are found, prompts you to select one
  4. Server Launch: Starts the development server and opens your browser

TestShip expects your Anchor project to have the following structure:

your-anchor-project/
├── Anchor.toml # Required: Anchor configuration
├── target/
│ ├── idl/
│ │ └── your_program.json # Required: Program IDL
│ └── deploy/
│ └── your_program.so # Program binary
├── programs/
└── tests/
  • Anchor.toml: Must exist in the project root
  • Built Program: Run anchor build before starting TestShip
  • IDL Files: At least one .json IDL file in target/idl/

If your Anchor workspace contains multiple programs, TestShip will prompt you to select which program to test:

Terminal window
$ testship start
Scanning for Anchor project...
Found Anchor project
? Found multiple Anchor programs. Select one: (Use arrow keys)
counter_program
voting_program
token_swap

Use arrow keys to navigate and press Enter to select.

TestShip runs a local development server that:

  • Serves the interactive UI at http://localhost:3000 (or your specified port)
  • Provides API endpoints for IDL and project information
  • Automatically opens your default browser to the UI

Error:

Error: No Anchor project found. Please run from Anchor project directory.

Solution: Navigate to your Anchor project root directory (where Anchor.toml is located).

Error:

Error: No IDL directory found.
Please run: anchor build

Solution: Build your Anchor program to generate the IDL:

Terminal window
anchor build

Error:

Error: No IDL files found.
Please run: anchor build

Solution: Ensure your program compiles successfully:

Terminal window
anchor build

If port 3000 is already in use, specify a different port:

Terminal window
testship start --port 3001