After initializing a Solana dapp using anchor init
and building it successfully with anchor build
, I attempted to run the anchor test
command. However, even though I haven't added any code yet, the test failed and presented me with the following 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)
The error indicates that there is no file inside the tests
directory, but in reality, there is a file named mydapp.ts
containing the following code:
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);
});
});