solana-developers / program-examples

A repository of Solana program examples
803 stars 300 forks source link

ts-mocha fails in typescript v5 on native projects #127

Open heyAyushh opened 1 month ago

heyAyushh commented 1 month ago
 Exception during run: TypeError: Unknown file extension ".ts" for  /solana/program-examples/basics/hello-solana/native/tests/test.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:214:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:240:36)
    at defaultLoad (node:internal/modules/esm/load:123:22)
    at ModuleLoader.load (node:internal/modules/esm/loader:567:7)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:45)
    at ModuleJob._link (node:internal/modules/esm/module_job:106:19) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

To fix this temporarily use these specific versions in node

  "devDependencies": {
    "@types/bn.js": "^5.1.0",
    "@types/chai": "^4.3.1",
    "@types/mocha": "^9.1.1",
    "chai": "^4.3.4",
    "mocha": "^9.0.3",
    "solana-bankrun": "^0.3.0",
    "ts-mocha": "^10.0.0",
    "typescript": "^4.3.5"
  },
deauthe commented 1 month ago

some say it's probably an issue with mocha. Any updates on this ?