`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 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);
});
});
我不得不全局安装 yarn,因为我的系统上没有它
sudo npm i -g yarn
然后我得到 ts-mocha
command not found 即使它在 package.json
上。所以我 运行 npm install
安装所有依赖项。然后我得到 ts node
错误
sudo npm i -g ts-node
终于成功了
我刚刚用 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);
});
});
我不得不全局安装 yarn,因为我的系统上没有它
sudo npm i -g yarn
然后我得到 ts-mocha
command not found 即使它在 package.json
上。所以我 运行 npm install
安装所有依赖项。然后我得到 ts node
错误
sudo npm i -g ts-node
终于成功了