Skip to main content

Usage

dokrypt test <subcommand> [flags]

Subcommands

SubcommandDescription
runRun tests
listList discovered test suites
reportShow the last test report

run

Discover and run tests with optional filtering, gas reporting, and coverage.
dokrypt test run [flags]

Flags

FlagTypeDefaultDescription
--suitestringRun a specific suite by name
--filterstringFilter tests by name substring
--parallelint4Maximum parallel test count
--gas-reportboolfalseGenerate gas usage report
--coverageboolfalseGenerate coverage report
--snapshotboolfalseEnable snapshot isolation per test
--timeoutdurationPer-test timeout (e.g., 30s, 2m)
--jsonboolfalseOutput results as JSON

Test File Discovery

Dokrypt automatically discovers tests based on file patterns:
LanguagePatternsRunner
Solidity*.t.sol, *.test.sol, *_test.solforge test
JavaScript*.test.js, *.jsnode or npx hardhat test
TypeScript*.test.ts, *.tsnpx hardhat test
Search directories (in order): test/, tests/, contracts/test/, or as configured in dokrypt.yaml.

Configuration via dokrypt.yaml

Test settings can also be configured in dokrypt.yaml:
tests:
  dir: test/
  timeout: 120s
  parallel: 8
  snapshot_isolation: true
  gas_report: true
  coverage: false
  suites:
    unit:
      pattern: "test/unit/**/*.t.sol"
      timeout: 30s
    integration:
      pattern: "test/integration/**/*.t.sol"
      timeout: 120s
      services: [ethereum, ipfs]
CLI flags take precedence over config values.

Built-in Validation Suite

If no test files are found, Dokrypt runs a built-in validation suite:
TestDescription
chain_is_runningBasic connectivity check
accounts_availableAt least one account exists
chain_id_validChain ID is non-zero
mining_worksCan mine blocks successfully
snapshot_restoreSnapshot and revert work correctly

Examples

# Run all tests
dokrypt test run

# Run with gas reporting
dokrypt test run --gas-report

# Filter by test name
dokrypt test run --filter "test_transfer"

# Run a specific suite
dokrypt test run --suite unit

# Run with snapshot isolation (each test gets a clean state)
dokrypt test run --snapshot

# Increase parallelism
dokrypt test run --parallel 8

# Set per-test timeout
dokrypt test run --timeout 1m

# Output JSON for CI pipelines
dokrypt test run --json > results.json

Example Output

Running test suite: contracts
  ✓ test_increment           12ms    gas: 26,342
  ✓ test_set_number           8ms    gas: 43,521
  ✓ test_decrement            9ms    gas: 26,342
  ✓ test_token_transfer      15ms    gas: 51,204

4 passed, 0 failed (44ms)

Gas Report:
  Counter.increment()     26,342 avg
  Counter.setNumber()     43,521 avg
  SimpleToken.transfer()  51,204 avg
Results are persisted to ~/.dokrypt/reports/<project>/latest.json.

list

List all discovered test suites.
dokrypt test list

Example Output

Suite          Tests   Description
contracts      4       Solidity contract tests
validation     5       Built-in chain validation

report

Show the results from the last test run.
dokrypt test report
Loads ~/.dokrypt/reports/<project>/latest.json and displays the results, including gas report if available.

Example Output

Last run: 2025-01-15 10:42:00 (44ms)

  ✓ test_increment           12ms
  ✓ test_set_number           8ms
  ✓ test_decrement            9ms
  ✓ test_token_transfer      15ms

4 passed, 0 failed