简体   繁体   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)

I just initialized a solana dapp with anchor init .我刚刚用anchor init初始化了一个 solana dapp。 Then I built successfully with anchor build .然后我使用anchor build成功构建。 I tried to test anchor test command too but it fails and I have not added any code yet.我也尝试测试anchor test命令,但它失败了,我还没有添加任何代码。 This is still untouched initialized code and this is the error message:这仍然是未修改的初始化代码,这是错误消息:

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

It says there is not file inside tests directory but there is mydapp.ts with this code它说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);
  });
});

I had to install yarn globally since I did not have it on my system我必须在全球范围内安装纱线,因为我的系统上没有它

 sudo  npm i -g yarn

Then I got ts-mocha command not found even though it was on package.json .然后我得到了ts-mocha command not found 即使它在package.json上。 so I run npm install to install all dependencies.所以我运行npm install来安装所有依赖项。 Then I got ts node error然后我得到了ts node错误

  sudo npm i -g ts-node

Finally it works终于成功了

暂无
暂无

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

相关问题 Typescript Nodejs Dockerfile:错误 TS5057:在指定目录中找不到 tsconfig.json 文件:'.' - Typescript Nodejs Dockerfile: error TS5057: Cannot find a tsconfig.json file at the specified directory: '.' 错误 TS5014:无法解析文件“tsconfig.json”:位置 57 处的意外令牌/JSON - error TS5014: Failed to parse file 'tsconfig.json': Unexpected token / in JSON at position 57 Mocha TS测试因npm test而失败,但如果直接运行则不会失败 - Mocha TS tests fail with `npm test` but not if run directly lerna monorepo 中的 tsconfig.json 继承出现 TS18003 错误 - TS18003 error with tsconfig.json inheritance in lerna monorepo Windows 10 tsc错误TS5007:无法解析引用的文件:tsconfig.json - Windows 10 tsc error TS5007: Cannot resolve referenced file: tsconfig.json ts-mocha 和 chai - 错误 TS2695:逗号运算符的左侧未使用且没有副作用 - ts-mocha and chai - error TS2695: Left side of comma operator is unused and has no side effects ts-node正在更改tsconfig.json文件 - ts-node is changing tsconfig.json file 如何对 .ts 文件运行 chutzpah 测试 - How to run a chutzpah test on a .ts file 当 Webpack ts-loader 显示“模块解析失败:意外令牌”时,tsconfig.json jsx 被保留 - tsconfig.json jsx is preserve when Webpack ts-loader shows "Module parse failed: Unexpected token" 在tsconfig.json中指定路径,而不使用相对路径:src / app / app.module.ts中的错误:错误TS2307:找不到模块“ @…” - Specify path in tsconfig.json instead of using relative path : ERROR in src/app/app.module.ts: error TS2307: Cannot find module '@…'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM