繁体   English   中英

`anchor test` 错误:无法运行测试:yarn run ts-mocha -p./tsconfig.json -t 1000000 tests/**/*.ts: No such file or directory (os error 2)

[英]`anchor test` error: Failed to run test: yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts: No such file or directory (os error 2)

我刚刚用anchor init初始化了一个 solana dapp。 然后我使用anchor build成功构建。 我也尝试测试anchor test命令,但它失败了,我还没有添加任何代码。 这仍然是未修改的初始化代码,这是错误消息:

Failed to run test: yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts: No such file or directory (os error 2)

它说tests目录中没有文件但是有mydapp.ts和这段代码

import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { Mydapp } from "../target/types/mycalculatordapp";

describe("mydapp", () => {
  // Configure the client to use the local cluster.
  anchor.setProvider(anchor.Provider.env());

  const program = anchor.workspace.Mydapp as Program<Mydapp>;

  it("Is initialized!", async () => {
    // Add your test here.
    const tx = await program.rpc.initialize({});
    console.log("Your transaction signature", tx);
  });
});

我必须在全球范围内安装纱线,因为我的系统上没有它

 sudo  npm i -g yarn

然后我得到了ts-mocha command not found 即使它在package.json上。 所以我运行npm install来安装所有依赖项。 然后我得到了ts node错误

  sudo npm i -g ts-node

终于成功了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM